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/?q=fetch&page=347&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 4158 results for "fetch"(397ms)

valTownChatGPT2main.tsx3 matches

@janpaul123•Updated 9 months ago
210 form.addEventListener("submit", (e) => {
211 e.preventDefault();
212 // make fetch POST request to /save and write the result to .saveValResult.
213 fetch("/save", {
214 method: "POST",
215 body: new FormData(form),
306});
307
308export default passwordAuth(app.fetch, { verifyPassword: verifyToken });

valwriter_outputmain.tsx2 matches

@stevekrouse•Updated 9 months ago
8
9app.get("/", async (c) => {
10 const response = await fetch(
11 `${BASE_URL}?q=Brooklyn&units=metric&appid=${WEATHER_API_KEY}`
12 );
20});
21
22export default app.fetch;

downloadSiteContentsmain.tsx2 matches

@nvie•Updated 9 months ago
25 let reason: string;
26 try {
27 res = await fetch(URL, { redirect: "follow" });
28 if (!res.ok) {
29 throw await res.text();
31 ok = true;
32 } catch (e) {
33 reason = `couldn't fetch: ${e}`;
34 await email({ subject: "could not update the contents of the change", text: reason });
35 }

azureDinosaurmain.tsx2 matches

@maxm•Updated 9 months ago
1import { fetchFile, toBlobURL } from "https://esm.sh/@ffmpeg/util";
2import { FFmpeg } from "https://maxm-emeraldox.web.val.run/@ffmpeg/ffmpeg";
3
8 wasmURL: `https://esm.sh/@ffmpeg/core@0.12.6/dist/umd/ffmpeg-core.wasm`,
9});
10console.log(FFmpeg, fetchFile, toBlobURL);

valwriter_outputmain.tsx2 matches

@janpaul123•Updated 9 months ago
1// This approach fetches weather data for Brooklyn, NY from the Open Meteo API
2
3// It then parses the response to extract the current temperature
6
7export default async function main() {
8 // Fetch weather data for Brooklyn, NY
9
10 const response = await axios.get(

sqlite_adminmain.tsx1 match

@johnsmith•Updated 9 months ago
9app.get("/", async (c) => c.html(await sqlite_admin_tables()));
10app.get("/:table", async (c) => c.html(await sqlite_admin_table(c.req.param("table"))));
11export default basicAuth(app.fetch);

getValsContextWindowmain.tsx7 matches

@janpaul123•Updated 9 months ago
69 );
70 });
71 export default app.fetch;`,
72 },
73 {
129 {
130 prompt: "Write a val that accesses environment variables",
131 code: `const res = await fetch("${API_URL}/v1/me", {
132 headers: {
133 Authorization: \`Bearer \${Deno.env.get("valtown")}\`,
141 code: `import process from "node:process";
142
143 const res = await fetch("${API_URL}/v1/me", {
144 headers: {
145 Authorization: \`Bearer \${process.env.valtown}\`,
165 code: `import cheerio from "npm:cheerio";
166
167 const response = await fetch("https://example.com");
168 const body = await response.text();
169 const $ = cheerio.load(body);
453 {
454 role: "user",
455 content: "Write a val that fetches the weather in Brooklyn, NY",
456 },
457 {
458 role: "assistant",
459 content:
460 "```ts\nexport default async function(req: Request): Promise<Response> {\n const apiKey = Deno.env.get(\"METEO_KEY\");\n const apiUrl = `https://api.open-meteo.com/v1/forecast?latitude=40.6782&longitude=-73.9442&hourly=temperature_2m&current_weather=true&apikey=${apiKey}`;\n\n const response = await fetch(apiUrl);\n const weatherData = await response.json();\n\n return new Response(JSON.stringify(weatherData), { headers: { \"Content-Type\": \"application/json\" } });\n}\n```",
461 },
462 {
467 role: "assistant",
468 content:
469 "```ts\n/** @jsxImportSource npm:hono@3/jsx */\nimport { Hono } from \"npm:hono\";\n\nconst app = new Hono();\napp.get(\"/\", async (c) => {\n return c.html(\n <div>\n <form>\n Your name: <input type=\"text\" name=\"name\" /> <input type=\"submit\" />\n </form>\n Hello {c.req.query(\"name\")}\n </div>,\n );\n});\nexport default app.fetch;\n```",
470 },
471 ...templatePrompts,

blob_adminmain.tsx2 matches

@janpaul123•Updated 9 months ago
1/** @jsxImportSource https://esm.sh/hono@4.0.8/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import view_route from "https://esm.town/v/pomdtr/blob_admin_blob";
5import create_route from "https://esm.town/v/pomdtr/blob_admin_create";
133});
134
135export default modifyFetchHandler(passwordAuth(app.fetch));

valwritermain.tsx6 matches

@janpaul123•Updated 9 months ago
2import { updateValByName } from "https://esm.town/v/nbbaier/updateValByName?v=14";
3import { basicAuth } from "https://esm.town/v/pomdtr/basicAuth?v=62";
4import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
5import { chat } from "https://esm.town/v/stevekrouse/openai";
6import cronstrue from "npm:cronstrue";
19It stores each line of the poem in sqlite.
20It has a textbox that lets anyone input a new line to the poem.`,
21 content: await fetchText("https://esm.town/v/stevekrouse/poembuilder3?v=4"),
22 },
23 {
24 user: "an app that uses chatgpt to convert natural language to cron syntax",
25 content: await fetchText("https://esm.town/v/stevekrouse/cron2"),
26 },
27];
29const app = new Hono();
30
31export default basicAuth(app.fetch);
32app.get("/", async (c) => {
33 const example = examples[Math.floor(Math.random() * examples.length)];
98 Write ONLY Deno TypeScript.
99
100 If you use Hono, use \`export default app.fetch;\` to start the server.
101
102 Only use web standard fetch.
103 // Our library for SQLite
104 import { sqlite } from "https://esm.town/v/std/sqlite";

randomCardImagemain.tsx4 matches

@jamiedubs•Updated 9 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export default async function(req: Request): Promise<Response> {
4 try {
5 const response = await fetch(
6 "https://deckofcardsapi.com/api/deck/new/draw/?count=1",
7 );
14 }
15 } catch (error) {
16 console.log("Error fetching random card image:", error);
17 return Response.json({
18 error: `An error occurred while fetching the random card image. ${error}`,
19 }, { status: 400 });
20 }

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

tweetFetcher2 file matches

@nbbaier•Updated 1 week ago