1import { email } from "https://esm.town/v/std/email?v=9";
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
9}
10
11const randomJoke = await fetchRandomJoke();
12const setup = randomJoke.setup;
13const punchline = randomJoke.punchline;
6import { email } from "https://esm.town/v/std/email?v=9";
7
8// Fetches a random joke.
9// function fetchRandomJoke() {
10// const SAMPLE_JOKE = {
11// "setup": "What do you call a group of disorganized cats?",
15// }
16
17// const randomJoke = fetchRandomJoke();
18// const setup = randomJoke.setup;
19// const punchline = randomJoke.punchline;
27// ... imports ...
28
29// Fetches a random joke.
30// function fetchRandomJoke() {
31// const response = fetch(
32// "https://official-joke-api.appspot.com/random_joke",
33// );
39// ... imports ...
40
41// Fetches a random joke.
42async function fetchRandomJoke() {
43 const response = await fetch(
44 "https://official-joke-api.appspot.com/random_joke",
45 );
47}
48
49const randomJoke = await fetchRandomJoke();
50const setup = randomJoke.setup;
51const punchline = randomJoke.punchline;
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { iframeHandler } from "https://esm.town/v/nbbaier/iframeHandler";
5import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
15import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth?v=70";
16import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
17import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
18import { Hono } from "npm:hono";
19import type { FC } from "npm:hono/jsx";
174});
175
176export const handler = app.fetch;
177export default iframeHandler(modifyFetchHandler(passwordAuth(handler)));
1export const newClient = async (username: string, password: string): Client => {
2 const url = `https://${username}-userspaceauth.web.val.run/validate/${password}`;
3 let resp = await fetch(url);
4 if (resp.status !== 200) {
5 throw new Error("Invliad response. Have you set up your fork? https://www.val.town/v/maxm/userspaceauth/fork?");
3// ... imports ...
4
5// Fetches a random joke.
6async function fetchRandomJoke() {
7 const response = await fetch(
8 "https://official-joke-api.appspot.com/random_joke",
9 );
11}
12
13const randomJoke = await fetchRandomJoke();
14const setup = randomJoke.setup;
15const punchline = randomJoke.punchline;
6// };
7
8// Fetches a random joke.
9// function fetchRandomJoke() {
10// const SAMPLE_JOKE = {
11// "setup": "What do you call a group of disorganized cats?",
15// return SAMPLE_JOKE;
16// }
17// Fetches a random joke.
18// Fetches a random joke.
19async function fetchRandomJoke() {
20 const response = await fetch(
21 "https://official-joke-api.appspot.com/random_joke",
22 );
23 return response.json();
24}
25const randomJoke = await fetchRandomJoke();
26const setup = randomJoke.setup;
27const punchline = randomJoke.punchline;
33});
34
35console.log(fetchRandomJoke());
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { iframeHandler } from "https://esm.town/v/nbbaier/iframeHandler";
5import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
15import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth?v=70";
16import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
17import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
18import { Hono } from "npm:hono";
19import type { FC } from "npm:hono/jsx";
174});
175
176export const handler = app.fetch;
177export default iframeHandler(modifyFetchHandler(passwordAuth(handler)));
9 return { "status": 400, "error_msg": "Valid URL is required as input. URL was empty." };
10 }
11 let resp = await fetch(url);
12 let text = await resp.text();
13 // We parse the page as HTML and then pick the data we want.
66
67async function getImageDataFromUrl(url) {
68 const response = await fetch(url);
69 const base64data = Buffer.from(await response.arrayBuffer()).toString("base64");
70 return "data:image/png;base64," + base64data;
1// Fetches a random joke.
2function fetchRandomJoke() {
3 const response = fetch(
4 "https://official-joke-api.appspot.com/random_joke",
5 );
6 return response;
7}
8function fetchRandomJoke() {
9 const SAMPLE_JOKE = {
10 "setup": "What do you call a group of disorganized cats?",
15}
16
17const randomJoke = fetchRandomJoke();
18console.log(randomJoke.setup); // This will print the setup to the console.
19console.log(randomJoke.punchline); // This will print the punchline to the console.
21import { email } from "https://esm.town/v/std/email?v=9";
22
23// Fetches a random joke.
24function fetchRandomJoke() {
25 const SAMPLE_JOKE = {
26 "setup": "What do you call a group of disorganized cats?",
30}
31
32const randomJoke = fetchRandomJoke();
33const setup = randomJoke.setup;
34const punchline = randomJoke.punchline;
40});
41
42// Fetches a random joke.
43async function fetchRandomJoke() {
44 const response = await fetch(
45 "https://official-joke-api.appspot.com/random_joke",
46 );
48}
49
50const randomJoke = await fetchRandomJoke();
51const setup = randomJoke.setup;
52const punchline = randomJoke.punchline;
1// ... imports ...
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
9}
10
11const randomJoke = await fetchRandomJoke();
12const setup = randomJoke.setup;
13const punchline = randomJoke.punchline;