1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
);
return response;
}
const randomJoke = await fetchRandomJoke();
const setup = randomJoke.setup;
const punchline = randomJoke.punchline;
// Sends an email with the joke.
export const emailRandomJoke = email({
text: punchline,
subject: setup,
});