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/$2?q=fetch&page=5&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 10800 results for "fetch"(704ms)

HN-fetch-callmain.tsx3 matches

@ImGqb•Updated 7 hours ago
1import { fetchItem, fetchMaxItemId } from "./api.tsx";
2
3export async function main(req: Request) {
10 switch (path) {
11 case "/max": {
12 const maxId = await fetchMaxItemId();
13 return Response.json({
14 ok: true,
25 }
26
27 const item = await fetchItem(id);
28
29 return Response.json({

cindex.ts1 match

@Sujal5•Updated 7 hours ago
41});
42
43export default app.fetch; // This is the entry point for HTTP vals

blob_adminmain.tsx1 match

@lm3m•Updated 7 hours ago
199});
200
201export default lastlogin((request: Request) => app.fetch(request));

blob_adminapp.tsx22 matches

@lm3m•Updated 7 hours ago
231 const [isDragging, setIsDragging] = useState(false);
232
233 const fetchBlobs = useCallback(async () => {
234 setLoading(true);
235 try {
236 const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
237 const data = await response.json();
238 setBlobs(data);
239 } catch (error) {
240 console.error("Error fetching blobs:", error);
241 } finally {
242 setLoading(false);
245
246 useEffect(() => {
247 fetchBlobs();
248 }, [fetchBlobs]);
249
250 const handleSearch = (e) => {
261 setBlobContentLoading(true);
262 try {
263 const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
264 const content = await response.text();
265 setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
266 setEditContent(content);
267 } catch (error) {
268 console.error("Error fetching blob content:", error);
269 } finally {
270 setBlobContentLoading(false);
275 const handleSave = async () => {
276 try {
277 await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
278 method: "PUT",
279 body: editContent,
287 const handleDelete = async (key) => {
288 try {
289 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
290 setBlobs(blobs.filter(b => b.key !== key));
291 if (selectedBlob && selectedBlob.key === key) {
304 const key = `${searchPrefix}${file.name}`;
305 formData.append("key", encodeKey(key));
306 await fetch("/api/blob", { method: "POST", body: formData });
307 const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
308 setBlobs([newBlob, ...blobs]);
312 }
313 }
314 fetchBlobs();
315 };
316
326 try {
327 const fullKey = `${searchPrefix}${key}`;
328 await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
329 method: "PUT",
330 body: "",
341 const handleDownload = async (key) => {
342 try {
343 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
344 const blob = await response.blob();
345 const url = window.URL.createObjectURL(blob);
360 if (newKey && newKey !== oldKey) {
361 try {
362 const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
363 const content = await response.blob();
364 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
365 method: "PUT",
366 body: content,
367 });
368 await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
369 setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
370 if (selectedBlob && selectedBlob.key === oldKey) {
380 const newKey = `__public/${key}`;
381 try {
382 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
383 const content = await response.blob();
384 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
385 method: "PUT",
386 body: content,
387 });
388 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
389 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
390 if (selectedBlob && selectedBlob.key === key) {
399 const newKey = key.slice(9); // Remove "__public/" prefix
400 try {
401 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
402 const content = await response.blob();
403 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
404 method: "PUT",
405 body: content,
406 });
407 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
408 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
409 if (selectedBlob && selectedBlob.key === key) {

HN-fetch-callapi.tsx4 matches

@ImGqb•Updated 8 hours ago
20const BaseUrl = "https://hacker-news.firebaseio.com/v0";
21
22export function fetchItem(id: number | string): Promise<Item> {
23 return fetch(`${BaseUrl}/item/${id}.json`).then(ret => ret.json());
24}
25
26export function fetchMaxItemId(): Promise<string> {
27 // https://hacker-news.firebaseio.com/v0/maxitem.json
28 return fetch(`${BaseUrl}/maxitem.json`).then(ret => ret.text());
29}

openaiproxymain.tsx2 matches

@skutaans•Updated 8 hours ago
27 const authHeader = req.headers.get("Proxy-Authorization") || req.headers.get("Authorization");
28 const token = authHeader ? parseBearerString(authHeader) : undefined;
29 const meRes = await fetch(`${API_URL}/v1/me`, { headers: { Authorization: `Bearer ${token}` } });
30 if (!meRes.ok) {
31 return new Response("Unauthorized", { status: 401 });
64 });
65
66 const openAIRes = await fetch(url, {
67 method: req.method,
68 headers,

url-to-markdownindex.html9 matches

@peterhartree•Updated 8 hours ago
77 }
78
79 async function fetchWithCORS(url) {
80 // Try direct fetch first
81 try {
82 const response = await fetch(url);
83 if (response.ok) {
84 return await response.text();
85 }
86 } catch (error) {
87 // If direct fetch fails due to CORS, try a CORS proxy
88 console.log('Direct fetch failed, trying CORS proxy...');
89 }
90
91 // Use a CORS proxy as fallback
92 const proxyUrl = `https://api.allorigins.win/get?url=${encodeURIComponent(url)}`;
93 const response = await fetch(proxyUrl);
94
95 if (!response.ok) {
96 throw new Error(`Failed to fetch: ${response.status} ${response.statusText}`);
97 }
98
103 async function extractArticle(url) {
104 try {
105 showStatus(`Fetching: ${url}`, 'info');
106
107 const html = await fetchWithCORS(url);
108
109 // Parse the HTML

url-to-markdownREADME.md2 matches

@peterhartree•Updated 8 hours ago
14## How It Works
15
161. **Content Fetching**: Attempts direct fetch first, falls back to CORS proxy if needed
172. **Article Extraction**: Uses Mozilla Readability to identify and extract main article content
183. **Markdown Conversion**: Converts the extracted HTML to clean Markdown using Turndown
49Works in all modern browsers that support:
50- ES6 modules
51- Fetch API
52- Clipboard API (for copy functionality)
53- DOMParser

Demoindex.ts1 match

@vinod•Updated 8 hours ago
196});
197
198export default app.fetch;

Demoindex.html2 matches

@vinod•Updated 8 hours ago
169 };
170
171 const response = await fetch('/api/measure', {
172 method: 'POST',
173 headers: {
209 };
210
211 const response = await fetch('/api/report', {
212 method: 'POST',
213 headers: {

HN-fetch-call2 file matches

@ImGqb•Updated 7 hours ago
fetch HackerNews by API

FRAMERFetchBasic1 file match

@bresnik•Updated 1 day ago