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=595&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 8288 results for "fetch"(997ms)

get_gemini_modelsmain.tsx2 matches

@kora•Updated 9 months ago
11 const API_KEY = process.env.GEMINI_API_KEY;
12
13 const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models?key=${API_KEY}`);
14
15 const data = await response.json();
22 return models;
23 } catch (error) {
24 console.error("Error fetching Gemini models:", error);
25 return [];
26 }

redAnglerfishREADME.md2 matches

@kora•Updated 9 months ago
1# Fetch
2
3Learn how to use proxied fetch

redAnglerfishmain.tsx2 matches

@kora•Updated 9 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3let result = await fetch("https://api64.ipify.org?format=json");
4let json = await result.json();
5console.log(json.ip);

valleGetValsContextWindowmain.tsx8 matches

@stevekrouse•Updated 9 months ago
1export default async function getValsContextWindow(model: any) {
2 const readmeVals: any = await (await fetch("https://janpaul123-readmevals.web.val.run/")).json();
3
4 const API_URL = "https://api.val.town";
58 );
59 });
60 export default app.fetch;`,
61 },
62 {
118 {
119 prompt: "Write a val that accesses environment variables",
120 code: `const res = await fetch("${API_URL}/v1/me", {
121 headers: {
122 Authorization: \`Bearer \${Deno.env.get("valtown")}\`,
130 code: `import process from "node:process";
131
132 const res = await fetch("${API_URL}/v1/me", {
133 headers: {
134 Authorization: \`Bearer \${process.env.valtown}\`,
154 code: `import cheerio from "npm:cheerio";
155
156 const response = await fetch("https://example.com");
157 const body = await response.text();
158 const $ = cheerio.load(body);
528 {
529 role: "user",
530 content: "Write a val that fetches the weather in Brooklyn, NY",
531 },
532 {
533 role: "assistant",
534 content:
535 "```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```",
536 },
537 {
542 role: "assistant",
543 content:
544 "```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```",
545 },
546 ...templatePrompts,

ipqsScoreChangeAlertmain.tsx1 match

@nickgolden•Updated 9 months ago
18
19export async function checkIp() {
20 const result = await fetch(`https://ipqualityscore.com/api/json/ip/${ipqsApiKey}/${ipAddress}`);
21 const newData = await result.json();
22

surfboardDemoSchedule2main.tsx2 matches

@szymonator•Updated 9 months ago
34 // YOU MAY NOW RUN THE FILE.
35
36 const data = await fetch(
37 `https://api.stage.teamsurfboard.com/api/v1/schedule?start=${start.toISOString()}&end=${end.toISOString()}`,
38 {
54
55function Demo({ data }) {
56 if (!data) return <p>Failed to fetch</p>;
57
58 function processData(data) {

blobCommentsReactmain.tsx5 matches

@keenanzucker•Updated 9 months ago
10
11 useEffect(() => {
12 async function fetchSchedule() {
13 await fetch("/schedule")
14 .then(response => {
15 return response.json();
21 }
22
23 fetchSchedule();
24 }, []);
25
62 const tomorrow = new Date(today);
63 tomorrow.setDate(tomorrow.getDate() + 1);
64 const data = await fetch(
65 `https://api.stage.teamsurfboard.com/api/v1/schedule?start=${today.toISOString()}&end=${tomorrow.toISOString()}`,
66 {
76});
77
78export default app.fetch;

codeOnValTownmain.tsx3 matches

@andreterron•Updated 9 months ago
37
38/**
39 * @param handler Fetch handler
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style }: { val?: ValRef; style?: string } = {},
52}
53
54export default modifyFetchHandler;

surfboardDemoSchedule2main.tsx2 matches

@keenanzucker•Updated 9 months ago
8 const tomorrow = new Date(today);
9 tomorrow.setDate(tomorrow.getDate() + 1);
10 const data = await fetch(
11 `https://api.stage.teamsurfboard.com/api/v1/schedule?start=${today.toISOString()}&end=${tomorrow.toISOString()}`,
12 {
36};
37function Schedule({ data }) {
38 if (!data) return <p>Failed to fetch</p>;
39
40 const [hours, setHours] = useState(10);

sourceOnGithubExamplemain.tsx1 match

@curtcox•Updated 9 months ago
28});
29
30export default app.fetch;

fetchPaginatedData2 file matches

@nbbaier•Updated 2 weeks ago

FetchBasic1 file match

@fredmoon•Updated 2 weeks ago