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=278&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 3107 results for "fetch"(524ms)

asciiNycCamerasmain.tsx4 matches

@maxm•Updated 10 months ago
35 document.getElementById("message").style.display = "none";
36 document.getElementById("close-btn").style.display = "flex";
37 await fetchImage(id);
38 };
39
85 });
86 };
87 let resp = await fetch("https://webcams.nyctmc.org/cameras/graphql", {
88 "headers": {
89 "content-type": "application/json",
190 async (c) =>
191 new Response(
192 (await fetch(
193 "https://gist.githubusercontent.com/maxmcd/fdbc8197e877ca052a55982cb85f14c9/raw/0b1191bdf1f5e8c8cc2b7deab2a1f934ffc4dc14/nyc.json",
194 )).body,
283 });
284});
285export default app.fetch;

valTownChatGPTmain.tsx1 match

@stevekrouse•Updated 10 months ago
133 return new Response(body, { headers: { "Content-Type": "text/event-stream" } });
134});
135export default app.fetch;

openAIStreamingREADME.md2 matches

@maxm•Updated 10 months ago
10assistant > Here are a few fun Val ideas you could build on Val Town:
11
121. **Random Joke Generator:** Fetch a random joke from an API and display it.
132. **Daily Weather Update:** Pull weather data for your location using an API and create a daily summary.
143. **Mini Todo List:** Create a simple to-do list app with add, edit, and delete functionalities.
154. **Chuck Norris Facts:** Display a random Chuck Norris fact sourced from an API.
165. **Motivational Quote of the Day:** Fetch and display a random motivational quote each day.
17
18Which one sounds interesting to you?

openAQLocationmain.tsx2 matches

@stevekrouse•Updated 10 months ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2import { msDay } from "https://esm.town/v/stevekrouse/msDay";
3
6 lon: number;
7}) => {
8 const { results } = await fetchJSON(
9 "https://api.openaq.org/v2/locations?"
10 + new URLSearchParams({

HTreeTreePmain.tsx14 matches

@maxm•Updated 10 months ago
32}`;
33
34const DEFAULT_REQUEST = `let resp = await fetch("http://localhost");
35const logIt = () => {
36 console.log(resp.status);
95 work.onmessage = (e) => {
96 try {
97 const resp: { logs: Log[]; error?: { message: string; stack: string }; requests: FetchInfo[] } = JSON.parse(
98 e.data,
99 );
133 );
134 }
135 async handleRequest(req: Request, requestId: string, fetchId: string): Promise<Response> {
136 let requestRow = parseResultSet<RequestRow>(
137 await sqlite.execute({
167 await sqlite.execute({
168 sql: `UPDATE requests SET handler_logs = json_insert(handler_logs, '$[#]',json(?)) WHERE id = ?`,
169 args: [JSON.stringify({ id: parseInt(fetchId), logs }), requestId],
170 });
171 return resp;
258 const requestId = req.headers.get("X-Request-ID");
259 if (requestId) {
260 const fetchId = req.headers.get("X-Fetch-ID");
261 req.headers.delete("X-Request-ID");
262 req.headers.delete("X-Fetch-ID");
263 return app.handleRequest(req, requestId, fetchId);
264 }
265 if (req.method === "GET") {
309 date: number;
310};
311type FetchInfo = {
312 id: number;
313 req: RequestObj;
319// outside of this function as it won't be available within the worker.
320const workerScript = () => {
321 const requests: FetchInfo[] = [];
322
323 let proxyUrl: string;
324 let requestId: number;
325 let fetchCount: number = 1;
326 let blobUrl: string;
327
332 .join("\n"));
333
334 globalThis.fetch = new Proxy(fetch, {
335 async apply(target, thisArg, args) {
336 const id = fetchCount++;
337 const ogUrl = args[0];
338 args[0] = proxyUrl;
340 args[1].headers = args[1].headers || {};
341 args[1].headers["X-Request-ID"] = requestId;
342 args[1].headers["X-Fetch-ID"] = id;
343 args[1].headers["X-Original-URL"] = ogUrl;
344 const req: RequestObj = {
349 };
350 delete req.headers["X-Request-ID"];
351 delete req.headers["X-Fetch-ID"];
352 delete req.headers["X-Original-URL"];
353 const stack = cleanStack((new Error()).stack).replaceAll(blobUrl, "./script.ts");

datme_home_geomain.tsx2 matches

@stevekrouse•Updated 11 months ago
2import date_me_doc_locations from "https://esm.town/v/stevekrouse/date_me_doc_locations";
3import Layout from "https://esm.town/v/stevekrouse/dateme_layout";
4import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
5import { Hono } from "npm:hono@3";
6
64const app = new Hono();
65app.get("/", Home);
66export default reloadOnSaveFetchMiddleware(app.fetch);

reloadOnSavemain.tsx2 matches

@stevekrouse•Updated 11 months ago
37
38/**
39 * @param handler http val's fetch handler
40 * @param vals to watch
41 */
42export function reloadOnSaveFetchMiddleware(
43 handler: (req: Request) => Response | Promise<Response>,
44 vals = [rootValRef()],

tanLadybugmain.tsx5 matches

@stevekrouse•Updated 11 months ago
30 event.preventDefault();
31 const formData = new FormData(form);
32 const response = await fetch('/', {
33 method: 'POST',
34 body: formData,
43 event.preventDefault();
44 const formData = new FormData(form);
45 const response = await fetch('/', {
46 method: 'POST',
47 body: formData,
135 event.preventDefault();
136 const formData = new FormData(form);
137 const response = await fetch('/', {
138 method: 'POST',
139 body: formData,
148 event.preventDefault();
149 const formData = new FormData(form);
150 const response = await fetch('/', {
151 method: 'POST',
152 body: formData,
219});
220
221export default valTownBadge(app.fetch, import.meta.url);

favFarmmain.tsx1 match

@stevekrouse•Updated 11 months ago
105});
106
107export default app.fetch;

blackRodentmain.tsx1 match

@stevekrouse•Updated 11 months ago
49app.get("/projects/Time_Blindness_Loud_Calendar_via_iOS_shortcuts", Time_Blindness_Loud_Calendar_via_iOS_shortcuts);
50
51export default app.fetch;

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

tweetFetcher2 file matches

@nbbaier•Updated 1 week ago