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=458&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 7867 results for "fetch"(1609ms)

jsonpubmain.tsx2 matches

@yawnxyz•Updated 5 months ago
1007app.get("/", (c) => c.html(html));
1008
1009// Export app.fetch for Val Town, otherwise export app
1010export default (typeof Deno !== "undefined" && Deno.env.get("valtown")) ? app.fetch : app;
1011

blob_adminmain.tsx22 matches

@steveVT•Updated 5 months ago
233 const [isDragging, setIsDragging] = useState(false);
234
235 const fetchBlobs = useCallback(async () => {
236 setLoading(true);
237 try {
238 const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
239 const data = await response.json();
240 setBlobs(data);
241 } catch (error) {
242 console.error("Error fetching blobs:", error);
243 } finally {
244 setLoading(false);
247
248 useEffect(() => {
249 fetchBlobs();
250 }, [fetchBlobs]);
251
252 const handleSearch = (e) => {
263 setBlobContentLoading(true);
264 try {
265 const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
266 const content = await response.text();
267 setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
268 setEditContent(content);
269 } catch (error) {
270 console.error("Error fetching blob content:", error);
271 } finally {
272 setBlobContentLoading(false);
277 const handleSave = async () => {
278 try {
279 await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
280 method: "PUT",
281 body: editContent,
289 const handleDelete = async (key) => {
290 try {
291 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
292 setBlobs(blobs.filter(b => b.key !== key));
293 if (selectedBlob && selectedBlob.key === key) {
306 const key = `${searchPrefix}${file.name}`;
307 formData.append("key", encodeKey(key));
308 await fetch("/api/blob", { method: "POST", body: formData });
309 const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
310 setBlobs([newBlob, ...blobs]);
314 }
315 }
316 fetchBlobs();
317 };
318
328 try {
329 const fullKey = `${searchPrefix}${key}`;
330 await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
331 method: "PUT",
332 body: "",
343 const handleDownload = async (key) => {
344 try {
345 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
346 const blob = await response.blob();
347 const url = window.URL.createObjectURL(blob);
362 if (newKey && newKey !== oldKey) {
363 try {
364 const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
365 const content = await response.blob();
366 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
367 method: "PUT",
368 body: content,
369 });
370 await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
371 setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
372 if (selectedBlob && selectedBlob.key === oldKey) {
382 const newKey = `__public/${key}`;
383 try {
384 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
385 const content = await response.blob();
386 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
387 method: "PUT",
388 body: content,
389 });
390 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
391 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
392 if (selectedBlob && selectedBlob.key === key) {
401 const newKey = key.slice(9); // Remove "__public/" prefix
402 try {
403 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
404 const content = await response.blob();
405 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
406 method: "PUT",
407 body: content,
408 });
409 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
410 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
411 if (selectedBlob && selectedBlob.key === key) {

chatgptchessmain.tsx3 matches

@tmcw•Updated 5 months ago
36
37 const { Chess } = await import("https://esm.sh/chess.js@1.0.0-beta.8")
38 const position = (await fetch(`/game/${game_id}`).then(r => r.json())).fen
39 const thinking = document.querySelector("#thinking")
40 thinking.className = "transition-opacity opacity-0"
69 thinking.className = "transition-opacity opacity-100"
70
71 const response = fetch(`/game/${game_id}`, {
72 method: "POST",
73 body: JSON.stringify({ san: move.san }),
278})
279
280export default app.fetch

workersmain.tsx8 matches

@temptemp•Updated 5 months ago
1/** @jsxImportSource npm:hono/jsx */
2import { fetch } from "https://esm.town/v/std/fetch";
3import { faker } from "npm:@faker-js/faker";
4import CryptoJS from "npm:crypto-js";
14 "sec-ch-ua-mobile": "?0",
15 "sec-ch-ua-platform": "\"Windows\"",
16 "sec-fetch-dest": "empty",
17 "sec-fetch-mode": "cors",
18 "sec-fetch-site": "same-origin",
19 "Referrer-Policy": "strict-origin-when-cross-origin",
20};
58}
59async function upload(formData: any, user: string) {
60 const _ = await fetch("https://workers.cloudflare.com/playground/api/worker", {
61 "headers": {
62 ...commonHeaders,
75app.get("/regUser", async (c) => {
76 const uuid = await uuidGen();
77 const uid = await fetch("https://workers.cloudflare.com/playground", {
78 "headers": {
79 "accept":
123 headers: {
124 "User-Agent": faker.internet.userAgent(),
125 "Sec-Fetch-Dest": "iframe",
126 "referer": "https://workers.cloudflare.com/",
127 "Cookie": `token=${token}`,
153 );
154});
155export default app.fetch;

immaculateTanMoosemain.tsx2 matches

@stevekrouse•Updated 5 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";
137});
138
139export default modifyFetchHandler(passwordAuth(app.fetch));

cfetchREADME.md1 match

@temptemp•Updated 5 months ago
1Migrated from folder: tools/cfetch

ddg_chatmain.tsx8 matches

@kauri•Updated 5 months ago
95 const getVQD = async () => {
96 try {
97 const response = await fetch(STATUS_URL, {
98 headers: {
99 "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.3",
102 });
103
104 console.log('VQD Fetch Headers:', Object.fromEntries(response.headers.entries()));
105 const newVQD = response.headers.get('x-vqd-4') || '';
106 console.log('Fetched VQD:', newVQD);
107 setVqd(newVQD);
108 return newVQD;
109 } catch (error) {
110 console.error('VQD Fetch Error:', error);
111 return '';
112 }
125 let currentVQD = vqd || await getVQD();
126
127 const response = await fetch(CHAT_URL, {
128 method: 'POST',
129 headers: {
381 if (request.url.includes('/api/status')) {
382 try {
383 const statusResponse = await fetch('https://duckduckgo.com/duckchat/v1/status', {
384 headers: {
385 "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.3",
400 } catch (error) {
401 console.error('Status Proxy Error:', error);
402 return new Response(JSON.stringify({ error: 'Failed to fetch VQD' }), {
403 status: 500,
404 headers: {
413 try {
414 const requestBody = await request.json();
415 const chatResponse = await fetch('https://duckduckgo.com/duckchat/v1/chat', {
416 method: 'POST',
417 headers: {

PSEoutagesmain.tsx4 matches

@andreterron•Updated 5 months ago
35}
36
37// ----- fetch or read from file
38
39async function fetchOutages() {
40 const res = await fetch(OUTAGES_URL);
41 const json = await res.json();
42 return json as OutagesJson;
101export async function getOutages() {
102 // const outagesJson = await readOutages();
103 const outagesJson = await fetchOutages();
104
105 // Create check

sqlite_adminmain.tsx1 match

@sitrucl•Updated 5 months ago
10app.get("/", async (c) => c.html(await sqlite_admin_tables()));
11app.get("/:table", async (c) => c.html(await sqlite_admin_table(c.req.param("table"))));
12export default basicAuth(app.fetch, { verifyUser: (_, password) => verifyToken(password) });

enchantingSilverPelicanmain.tsx4 matches

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

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago