skip to Main Content

Javascript – Handling Unexpected "undefined" When Calling a Joke API

let url = "https://v2.jokeapi.dev/joke/Programming,Miscellaneous,Dark,Pun,Spooky?blacklistFlags=nsfw,religious,political,racist,explicit"; let btn = document.querySelector("button"); let result = document.querySelector("#result"); // Moved result selection outside the click event listener btn.addEventListener("click", async () => { let joke = await getJokes(); result.innerText = joke.setup; // Display setup immediately // setTimeout(()…

VIEW QUESTION
Back To Top
Search