Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/image-url.jpg%20%22Optional%20title%22?q=fetch&page=1091&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=fetch

Returns an array of strings in format "username" or "username/projectName"

Found 12525 results for "fetch"(1597ms)

getOpengraphMetadatamain.tsx2 matches

@dvsj•Updated 1 year ago
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;

roseGullmain.tsx12 matches

@carissacha•Updated 1 year ago
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;

moccasinTahrmain.tsx4 matches

@shivaanneu•Updated 1 year ago
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;

orangeReptilemain.tsx3 matches

@vsp05•Updated 1 year ago
1import { email } from "https://esm.town/v/std/email?v=9";
2
3async function fetchRandomJoke() {
4 const response = await fetch(
5 "https://official-joke-api.appspot.com/random_joke",
6 );
8}
9
10const randomJoke = await fetchRandomJoke();
11const setup = randomJoke.setup;
12const punchline = randomJoke.punchline;

userspaceAuthmain.tsx1 match

@maxm•Updated 1 year ago
99 return c.json(match, match ? 200 : 401);
100});
101export default app.fetch;
102
103// console.log(await opaque.getOpaqueConfig(opaque.OpaqueID.OPAQUE_P521).ake.generateAuthKeyPair());

untitled_moccasinAmphibianmain.tsx2 matches

@kisen•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2import { queryAQI } from "https://esm.town/v/kisen/queryAQI";
3
4export const untitled_moccasinAmphibian = (async () => {
5 let weather = queryAQI("beijing");
6 let push = fetchJSON(
7 "https://api.day.app/UadTW6YQF2ceiAxypDgHe/Body",
8 );

http_client_componentmain.tsx1 match

@pomdtr•Updated 1 year ago
87 ),
88 );
89 const resp = await fetch(req);
90 setResponse(resp);
91 }}

sqliteExplorerApp_DEVmain.tsx4 matches

@nbbaier•Updated 1 year ago
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
2import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
3import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
4import { sqlToCSV, sqlToJSON } from "https://esm.town/v/nbbaier/sqliteExportHelpers";
14import { Statement } from "https://esm.town/v/postpostscript/sqliteBuilder";
15import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
16import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
17import { Hono } from "npm:hono";
18import type { FC } from "npm:hono/jsx";
173});
174
175export const handler = app.fetch;
176export default reloadOnSaveFetchMiddleware(passwordAuth(handler));

codeOnValTownmain.tsx3 matches

@pomdtr•Updated 1 year ago
38
39/**
40 * @param handler Fetch handler
41 * @param val Define which val should open
42 */
43export function modifyFetchHandler(
44 handler: (req: Request) => Response | Promise<Response>,
45 { val, style }: { val?: ValRef; style?: string } = {},
63};
64
65export default modifyFetchHandler;

codeOnValTownREADME.md6 matches

@pomdtr•Updated 1 year ago
11Here are 2 different ways to add the "Code on Val Town" ribbon:
12
13### 1. Wrap your fetch handler (recommended)
14
15```ts
16import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=45";
17import { html } from "https://esm.town/v/stevekrouse/html?v=5";
18
19export default modifyFetchHandler(async (req: Request): Promise<Response> => {
20 return html(`<h2>Hello world!</h2>`);
21});
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`
54- `modifyHtmlString("<html>...", {val: { handle: "andre", name: "foo" }})`
55
58You can set the style parameter to a css string to customize the ribbon. Check out [github-fork-ribbon-css](https://github.com/simonwhitaker/github-fork-ribbon-css?tab=readme-ov-file#styling) to learn more about how to style the element.
59
60- `modifyFetchHandler(handler, {style: ".github-fork-ribbon:before { background-color: #333; }"})`
61- `modifyHtmlString("<html>...", {style: ".github-fork-ribbon:before { background-color: #333; }"})`
62
64
65```ts
66modifyFetchHandler(handler, {style: `@media (max-width: 768px) {
67 .github-fork-ribbon {
68 display: none !important;

fetch-socials4 file matches

@welson•Updated 1 day ago
fetch and archive my social posts

fetchRssForSubcurrent2 file matches

@ashryanio•Updated 1 day ago