Back

Version 16

12/4/2023
export const SAMPLE_JOKE = {
"setup": "What's black and white and read all over?",
"punchline": "The newspaper.",
};

import { email } from "https://esm.town/v/std/email?v=9";

// Fetches a random joke.
// Fetches a random joke.
function fetchRandomJoke() {
const response = fetch(
"https://official-joke-api.appspot.com/random_joke",
);
return response;
}

const randomJoke = fetchRandomJoke();
const setup = randomJoke.setup;
const punchline = randomJoke.punchline;

// Sends an email with the joke.
export const emailRandomJoke = email({
text: punchline,
subject: setup,
});
Updated: December 4, 2023