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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
export const SAMPLE_JOKE = {
"setup": "What do you call a group of disorganized cats?",
"punchline": "A cat-tastrophe.",
};
import { email } from "https://esm.town/v/std/email?v=9";
// Fetches a random joke.
// function fetchRandomJoke() {
// const SAMPLE_JOKE = {
// "setup": "What do you call a group of disorganized cats?",
// "punchline": "A cat-tastrophe.",
// };
// return SAMPLE_JOKE;
// }
// 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,
// });
// ... imports ...
// Fetches a random joke.
// function fetchRandomJoke() {
// const response = fetch(
// "https://official-joke-api.appspot.com/random_joke",
// );
// return response.json();
// }
// ... other code ...
// ... imports ...
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
);
return response.json();
}
const randomJoke = await fetchRandomJoke();
const setup = randomJoke.setup;
const punchline = randomJoke.punchline;
// ... email sending logic ...
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
April 8, 2024