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=377&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 7669 results for "fetch"(866ms)

bombCycloneOutageTrackermain.tsx3 matches

@andreterron•Updated 3 months ago
25
26 useEffect(() => {
27 async function fetchData() {
28 const response = await fetch("/outages");
29 const json = await response.json();
30 let firstEntry: { i: number; time: number; date: Date } = { i: -1, time: Date.now(), date: new Date() };
92 setOutageData(data);
93 }
94 fetchData();
95 }, []);
96

website_Summarizermain.tsx16 matches

@arfan•Updated 3 months ago
52 }, []);
53
54 const fetchAndSummarize = async () => {
55 if (!siteUrl) {
56 setError("Please enter a valid site URL");
63 setSiteInfo(null);
64 setProgress(10);
65 console.log("Starting fetchAndSummarize");
66
67 try {
68 // 1) Fetch site data
69 setProgress(30);
70 console.log("Fetching site details");
71 const siteResponse = await fetch(`/site-data?url=${encodeURIComponent(siteUrl)}`);
72 if (!siteResponse.ok) {
73 throw new Error(`Failed to fetch site details: ${siteResponse.statusText}`);
74 }
75 const siteData = await siteResponse.json();
76 setSiteInfo(siteData);
77 console.log("Site details fetched", siteData);
78
79 // 2) Summarize site content
80 setProgress(60);
81 console.log("Sending summary request");
82 const summaryResponse = await fetch("/summarize", {
83 method: "POST",
84 headers: {
102 console.log("Summarization complete");
103 } catch (err) {
104 console.error("Fetch Error:", err);
105 setError(`Error: ${err.message}`);
106 setLoading(false);
111 const handleKeyDown = (event) => {
112 if (event.key === "Enter" && !loading) {
113 fetchAndSummarize();
114 }
115 };
138 />
139 <button
140 onClick={fetchAndSummarize}
141 disabled={loading}
142 className="bg-orange-500 text-white p-3 rounded-r-lg hover:bg-orange-600 disabled:opacity-50 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-orange-500"
271 // Scrapes the HTML and returns minimal metadata
272 if (request.method === "GET" && pathname === "/site-data") {
273 console.log("Fetching site data");
274 const siteUrl = searchParams.get("url");
275 if (!siteUrl) {
281
282 try {
283 // Fetch the HTML from the site
284 const siteResponse = await fetch(siteUrl);
285 if (!siteResponse.ok) {
286 throw new Error(`Failed to fetch site: ${siteResponse.statusText}`);
287 }
288 const siteHtml = await siteResponse.text();
310 });
311 } catch (error) {
312 console.error("Error fetching site data:", error);
313 return new Response(JSON.stringify({ error: error.message }), {
314 status: 500,

epgmain.tsx6 matches

@taoji•Updated 3 months ago
1const Config = {
2 repository: 'e.erw.cc',
3 FETCH_TIMEOUT: 3000, // 3 seconds timeout
4 CACHE_DURATION: 1000 * 60 * 60 // 1 hour cache
5};
8const EPG_CACHE = new Map();
9
10async function timeoutFetch(request, timeout = Config.FETCH_TIMEOUT) {
11 const controller = new AbortController();
12 const timeoutId = setTimeout(() => controller.abort(), timeout);
13
14 try {
15 const response = await fetch(request, {
16 signal: controller.signal,
17 headers: {
18 'User-Agent': 'ValTown EPG Fetcher',
19 'Accept': 'application/json'
20 }
66
67 try {
68 const res = await timeoutFetch(new Request(`https://github.com/celetor/epg/releases/download/${tag}/112114.json`, request));
69 const data = await res.json();
70
96 return makeRes(JSON.stringify(program_info), 200, { 'content-type': 'application/json' });
97 } catch (error) {
98 console.error('EPG Fetch Error:', error);
99 return makeRes(JSON.stringify({
100 date,

geminicodermain.tsx1 match

@arfan•Updated 3 months ago
181
182 try {
183 const response = await fetch("/", {
184 method: "POST",
185 body: JSON.stringify({

blog_test_25_1_11main.tsx8 matches

@arfan•Updated 3 months ago
23
24 useEffect(() => {
25 fetchPosts();
26 }, []);
27
28 const fetchPosts = async () => {
29 try {
30 const response = await fetch("/api/posts");
31 if (!response.ok) throw new Error("Failed to fetch posts");
32 const data = await response.json();
33 setPosts(data);
41 const handleCreatePost = async (post: Omit<BlogPost, "id" | "date">) => {
42 try {
43 const response = await fetch("/api/posts", {
44 method: "POST",
45 headers: { "Content-Type": "application/json" },
47 });
48 if (!response.ok) throw new Error("Failed to create post");
49 await fetchPosts();
50 setIsFormOpen(false);
51 } catch (err) {
56 const handleUpdatePost = async (post: BlogPost) => {
57 try {
58 const response = await fetch(`/api/posts/${post.id}`, {
59 method: "PUT",
60 headers: { "Content-Type": "application/json" },
62 });
63 if (!response.ok) throw new Error("Failed to update post");
64 await fetchPosts();
65 setSelectedPost(null);
66 setIsFormOpen(false);

blob_adminmain.tsx23 matches

@sorcoro•Updated 3 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) {
826});
827
828export default lastlogin((request: Request) => app.fetch(request));

sqliteExplorerAppmain.tsx4 matches

@maxwell•Updated 3 months ago
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { iframeHandler } from "https://esm.town/v/nbbaier/iframeHandler";
5import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
16import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
17import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
18import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
19import { Hono } from "npm:hono";
20import type { FC } from "npm:hono/jsx";
175});
176
177export const handler = app.fetch;
178export default iframeHandler(modifyFetchHandler(passwordAuth(handler, { verifyPassword: verifyToken })));

cerebras_codermain.tsx1 match

@arthrod•Updated 3 months ago
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({

searchClosestWikimain.tsx4 matches

@gaimeri17•Updated 3 months ago
1// Stripping HTML from the final output before sending the response
2import { fetch } from "https://esm.town/v/std/fetch";
3
4export const searchClosestWiki = async (req: Request) => {
18 encodeURIComponent(searchQuery)
19 }&srwhat=text&format=json&utf8=1&origin=*`;
20 const searchResponse = await fetch(searchUrl);
21 const searchData = await searchResponse.json();
22
32 encodeURIComponent(pageTitle)
33 }&format=json&utf8=1&origin=*`;
34 const contentResponse = await fetch(contentUrl);
35 const contentData = await contentResponse.json();
36 const pageId = Object.keys(contentData.query.pages)[0];
45 });
46 } catch (err) {
47 return new Response(`Error fetching Wikipedia data: ${err.message}`, {
48 status: 200, // Internal Server Error
49 headers: { "Content-Type": "text/plain" },

competentMaroonFlymain.tsx1 match

@kmaisolutions•Updated 3 months ago
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago