diff --git a/fun/joke.js b/fun/joke.js new file mode 100644 index 0000000..3e60314 --- /dev/null +++ b/fun/joke.js @@ -0,0 +1 @@ +javascript:async function joke(){try{var response=await fetch("https://official-joke-api.appspot.com/random_joke");if(!response.ok){throw new Error(`Response status: ${response.status }`)}var json=await response.json();return[json.setup,json.punchline]}catch(error){console.error(error.message);return["Error","Failed to fetch joke"]}}joke().then(jokeArray=>{alert(jokeArray[0]);alert(jokeArray[1])});