Runs every 1 days
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
);
// Check if the request was successful (status code 200)
if (!response.ok) {
throw new Error(`Failed to fetch joke. Status: ${response.status}`);
}
const data = await response.json();
return data;
}
// Export the fetched random joke
export const randomJoke = await fetchRandomJoke();
// Usage example
const setup = randomJoke.setup;
const punchline = randomJoke.punchline;
console.log("Setup:", setup);
console.log("Punchline:", punchline);