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=474&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 8158 results for "fetch"(3623ms)

petunia_chatmain.tsx6 matches

@robertmccallnz•Updated 5 months ago
137
138 try {
139 const response = await fetch('/chat', {
140 method: 'POST',
141 headers: {
260 }
261
262 async function fetchMarketInsights() {
263 try {
264 const response = await fetch('/market-data', {
265 method: 'GET',
266 headers: { 'Accept': 'application/json' }
268
269 if (!response.ok) {
270 throw new Error('Failed to fetch market data');
271 }
272
298 }
299
300 refreshButton.addEventListener('click', fetchMarketInsights);
301 </script>
302 <footer>
368});
369
370export default app.fetch;

forEmulated1main.tsx1 match

@manyone•Updated 5 months ago
46 setIsRefining(isInitial ? false : true);
47 try {
48 const response = await fetch('/generate-landing-page', {
49 method: 'POST',
50 headers: {

LotecaV2main.tsx1 match

@maxm•Updated 5 months ago
62
63 try {
64 const resposta = await fetch(url);
65
66 if (!resposta.ok) {

md_links_resolvermain.tsx7 matches

@argimko•Updated 5 months ago
19 try {
20 isAutoProcessing.value = true;
21 const response = await fetch("/resolve-links", {
22 method: "POST",
23 headers: { "Content-Type": "application/json" },
350
351async function resolveRedirect(url: string): Promise<string> {
352 const fetchOptions = {
353 headers: {
354 "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
357
358 try {
359 // Method 1: Fetch with manual redirect handling
360 try {
361 const response = await fetch(url, {
362 ...fetchOptions,
363 method: "HEAD",
364 redirect: "manual"
373 // Method 2: Full GET request for stubborn redirects
374 try {
375 const fullResponse = await fetch(url, {
376 ...fetchOptions,
377 method: "GET",
378 redirect: "follow"

versatileBlackKitemain.tsx3 matches

@eligosmlytics•Updated 5 months ago
25 const proxyImage = async (imageUrl: string, index: number) => {
26 try {
27 const response = await fetch(`/proxy-image?url=${encodeURIComponent(imageUrl)}`);
28 if (response.ok) {
29 const proxyUrl = await response.text();
222
223 try {
224 const imageResponse = await fetch(imageUrl, {
225 headers: {
226 'User-Agent': 'Mozilla/5.0',
230
231 if (!imageResponse.ok) {
232 return new Response('Image fetch failed', { status: imageResponse.status });
233 }
234

embedVideoWebPagemain.tsx4 matches

@eligosmlytics•Updated 5 months ago
26 const proxyImage = async (imageUrl: string, index: number) => {
27 try {
28 const response = await fetch(`/proxy-image?url=${encodeURIComponent(imageUrl)}`, {
29 headers: {
30 'Cache-Control': 'no-cache' // Ensure fresh fetch
31 }
32 });
233
234 try {
235 const imageResponse = await fetch(imageUrl, {
236 headers: {
237 'User-Agent': 'Mozilla/5.0',
242
243 if (!imageResponse.ok) {
244 return new Response('Image fetch failed', { status: imageResponse.status });
245 }
246

p5_latest_starterkitmain.tsx4 matches

@ff6347•Updated 5 months ago
5const getNpmTarball = async (scope, packageName, version = "latest") => {
6 const fullPackageName = scope ? `@${scope}/${packageName}` : packageName;
7 const response = await fetch(`https://registry.npmjs.org/${fullPackageName}/${version}`);
8
9 if (!response.ok) {
10 throw new Error(`Failed to fetch metadata for ${fullPackageName}`);
11 }
12
30 const zip = new JSZip();
31
32 // Fetch latest versions of modules from npm registry
33 const moduleContents = await Promise.all(
34 modules.map(async (moduleName) => {
42 const tarballUrl = await getNpmTarball(scope, packageName);
43
44 const tarballResponse = await fetch(tarballUrl);
45
46 if (!tarballResponse.ok) {

blob_adminmain.tsx23 matches

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

superbAzureSharkmain.tsx23 matches

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

cerebras_codermain.tsx7 matches

@binaco•Updated 5 months ago
36
37 useEffect(() => {
38 async function fetchStats() {
39 const response = await fetch("/dashboard-stats");
40 const data = await response.json();
41 setStats(data);
42 }
43 fetchStats();
44 }, []);
45
128
129 useEffect(() => {
130 async function fetchUsageStats() {
131 const response = await fetch("/usage-stats");
132 const data = await response.json();
133 setUsageStats(data);
134 }
135 fetchUsageStats();
136 }, []);
137
141
142 try {
143 const response = await fetch("/", {
144 method: "POST",
145 body: JSON.stringify({

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago