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/$%7Burl%7D?q=fetch&page=1&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 14486 results for "fetch"(1329ms)

blob_adminmain.tsx1 match

@snptrsâ€ĸUpdated 1 hour ago
199});
200
201export default lastlogin((request: Request) => app.fetch(request));

blob_adminapp.tsx22 matches

@snptrsâ€ĸUpdated 1 hour 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) {

brokenLinkCrawlerurlGetter.tsx1 match

@willthereaderâ€ĸUpdated 1 hour ago
1export async function urlGetter(sourceURl) {
2 // convert object to array containing arrays with key value pairs. use map to iterate over the values then convert arrays to objects
3 const response = await fetch(sourceURl);
4 const html = await response.text();
5 const matches = [...html.matchAll(/<a[^>]*href="([^"]+)"[^>]*>(.*?)<\/a>/g)].map((match) => match[1]);

valSourceREADME.md3 matches

@curtcoxâ€ĸUpdated 1 hour ago
25```
26
27This will fetch the source from `https://esm.town/v/nbbaier/sqliteExplorerApp@100-main/main.tsx` and display it with annotations.
28
29### Custom Functions
122
1231. **URL Parsing**: Extracts the val path from the URL
1242. **Source Fetching**: Fetches source code from `https://esm.town/v/{path}`
1253. **Language Detection**: Determines language from file extension
1264. **Syntax Highlighting**: Applies syntax highlighting using Prism.js
141## Error Handling
142
143- Returns 404 if the source URL cannot be fetched
144- Returns 400 for invalid path formats
145- Returns 500 for other errors with error messages

valSourceindex.ts6 matches

@curtcoxâ€ĸUpdated 1 hour ago
168
169 try {
170 // Fetch the source code
171 const response = await fetch(sourceUrl);
172 if (!response.ok) {
173 return c.text(`Failed to fetch source: ${response.status}`, 404);
174 }
175
380 async function detectBlock(code, line, column) {
381 if (blockDetectorUrl) {
382 const response = await fetch(blockDetectorUrl, {
383 method: 'POST',
384 headers: { 'Content-Type': 'application/json' },
393 async function explainBlock(code, blockInfo) {
394 if (blockExplainerUrl) {
395 const response = await fetch(blockExplainerUrl, {
396 method: 'POST',
397 headers: { 'Content-Type': 'application/json' },
538}
539
540export default app.fetch;

reactHonoStarterApp.tsx2 matches

@spookyuserâ€ĸUpdated 1 hour ago
53 mutationFn: async () => {
54 // Get quantum bytes
55 const res = await fetch("/api/random-dewey");
56 if (!res.ok) {
57 throw new Error(
58 "Failed to fetch random numbers. The quantum source might be temporarily unavailable."
59 );
60 }

reactHonoStarterindex.ts1 match

@spookyuserâ€ĸUpdated 1 hour ago
37});
38
39export default app.fetch; // This is the entry point for HTTP vals
40

newvalmain.tsx3 matches

@wahobdâ€ĸUpdated 5 hours ago
5// Key-Value DB āĻĨ⧇āϕ⧇ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāĻ“ā§ŸāĻžāϰ āĻĢāĻžāĻ‚āĻļāύ
6async function kvGet(key: string): Promise<number> {
7 const res = await fetch(`https://api.val.town/v1/kv/get?key=${key}`, {
8 headers: { "X-API-Key": API_KEY },
9 });
15// Key-Value DB āϤ⧇ āĻ­ā§āϝāĻžāϞ⧁ āϏ⧇āϟ āĻ•āϰāĻžāϰ āĻĢāĻžāĻ‚āĻļāύ
16async function kvSet(key: string, value: number) {
17 await fetch(`https://api.val.town/v1/kv/set`, {
18 method: "POST",
19 headers: {
49// āĻŽā§‡āϏ⧇āϜ āĻĒāĻžāĻ āĻžāύ⧋āϰ āĻĢāĻžāĻ‚āĻļāύ
50async function sendMessage(chat_id: number, text: string, reply_markup: any = null) {
51 await fetch(`https://api.telegram.org/bot${BOT_TOKEN}/sendMessage`, {
52 method: "POST",
53 headers: { "Content-Type": "application/json" },

reactHonoStarterindex.ts2 matches

@n4k0m3â€ĸUpdated 5 hours ago
21});
22
23// HTTP vals expect an exported "fetch handler"
24// This is how you "run the server" in Val Town with Hono
25export default app.fetch;

saveImdbToDebridindex.ts7 matches

@larryhudsonâ€ĸUpdated 5 hours ago
39 : authHeader;
40
41 // Fetch streams from Torrentio
42 const torrentioUrl = `https://torrentio.strem.fun/realdebrid=${rdToken}/stream/movie/${imdbId}.json`;
43
44 console.log(`Fetching streams from: ${torrentioUrl}`);
45
46 const torrentioResponse = await fetch(torrentioUrl);
47 if (!torrentioResponse.ok) {
48 return new Response(`Error: Failed to fetch streams from Torrentio (${torrentioResponse.status}: ${torrentioResponse.statusText})`, {
49 status: 500,
50 headers: { 'Content-Type': 'text/plain' }
131 if (isCached) {
132 // Stream is already cached, just make the range request
133 const rangeResponse = await fetch(selectedStream.url, {
134 headers: {
135 'Range': 'bytes=0-0' // Request only the first byte
146
147 // First, make a request to initiate the download
148 const downloadResponse = await fetch(selectedStream.url, {
149 method: 'GET',
150 headers: {
162 } else {
163 // Fallback for streams that don't match our expected patterns
164 const rangeResponse = await fetch(selectedStream.url, {
165 headers: {
166 'Range': 'bytes=0-0'

testWeatherFetcher1 file match

@sjaskeprutâ€ĸUpdated 2 days ago

weatherFetcher1 file match

@sjaskeprutâ€ĸUpdated 2 days ago