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=583&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 8238 results for "fetch"(1788ms)

currencymain.tsx3 matches

@maraoz•Updated 9 months ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export let currency = async (desired, base = "usd", amount = 1) => {
4 let { rates } = await fetchJSON(`https://open.er-api.com/v6/latest/${base}`);
5 if (rates && rates[desired.toUpperCase()]) return amount * (rates[desired.toUpperCase()]);
6 else {
7 let { rates } = await fetchJSON(
8 `https://api.coingecko.com/api/v3/exchange_rates?&x_cg_demo_api_key=${Deno.env.get("COINGECKO_API_KEY")}`,
9 );

FetchREADME.md2 matches

@niek•Updated 9 months ago
1# Fetch Template
2Example template to quickly get started with a backend for Fetch in Framer.

VALLErunmain.tsx2 matches

@janpaul123•Updated 9 months ago
918 code: newCode,
919 });
920 fetch('/save', { method: "POST", body }).then(() => {
921 document.getElementById('code-input-hidden').value = newCode;
922 document.getElementById('preview-iframe').src += '';
1284 app.post("/", mainHandler);
1285
1286 return passwordAuth(app.fetch, { verifyPassword: verifyToken });
1287}

FetchREADME.md2 matches

@komolkin•Updated 9 months ago
1# Fetch Template
2Example template to quickly get started with a backend for Fetch in Framer.

Fetchmain.tsx1 match

@komolkin•Updated 9 months ago
10});
11
12export default app.fetch;

resyAuthmain.tsx2 matches

@stevekrouse•Updated 9 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { resyPublicAPIKey } from "https://esm.town/v/vtdocs/resyPublicAPIKey";
3
9 }[];
10}> => {
11 const authRes = await fetch("https://api.resy.com/3/auth/password", {
12 "headers": {
13 "authorization":

honoWithUnkeyRateLimitingmain.tsx1 match

@dthyresson•Updated 9 months ago
45});
46
47export default app.fetch;

distinctGoldLarkmain.tsx2 matches

@tempguy•Updated 9 months ago
13const apiUrl = "https://filehaus.top/api/upload/data.json"; // Replace with your API URL
14
15// Send the file using fetch
16try {
17 const response = await fetch(apiUrl, {
18 method: "POST",
19 body: formData,

valleGetValsContextWindowmain.tsx8 matches

@janpaul123•Updated 9 months ago
11 }
12
13 const readmeVals: any = await (await fetch("https://janpaul123-readmevals.web.val.run/")).json();
14
15 const API_URL = "https://api.val.town";
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,

githubActivityReportmain.tsx2 matches

@elliotbraem•Updated 9 months ago
14 }
15
16 const response = await fetch(`https://api.github.com/users/${userName}/events`);
17 const events = await response.json();
18
19 if (!events) {
20 return new Response(JSON.stringify({ ok: false, error: "Failed to fetch events" }), {
21 headers: { "Content-Type": "application/json" },
22 status: 500,

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago