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=1014&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 13595 results for "fetch"(3553ms)

SermonGPTUImain.tsx9 matches

@manyone•Updated 6 months ago
91 const [autoScroll, setAutoScroll] = useState(true);
92
93 // Fetch saved sermons on component mount
94 useEffect(() => {
95 const fetchSermons = async () => {
96 try {
97 const response = await fetch(`${endpointURL}/sermons`);
98 const data = await response.json();
99 console.log("Fetched sermons:", data); // Debugging log
100 // Ensure data is an array, even if it's empty
101 setSermons(Array.isArray(data) ? data : []);
102 } catch (error) {
103 console.error("Failed to fetch sermons:", error);
104 // Set to empty array in case of error
105 setSermons([]);
107 };
108
109 fetchSermons();
110 }, []);
111
169
170 try {
171 const response = await fetch(`${endpointURL}/delete-sermon/${sermonId}`, {
172 method: "DELETE",
173 });
200
201 try {
202 const res = await fetch(`${endpointURL}/save-sermon`, {
203 method: "POST",
204 headers: {
233
234 try {
235 const res = await fetch(`${endpointURL}/stream`, {
236 method: "POST",
237 body: JSON.stringify({ question }),

legendaryRoseSwordfishmain.tsx9 matches

@ronr•Updated 6 months ago
16
17 useEffect(() => {
18 fetchData();
19 }, []);
20
21 const fetchData = async () => {
22 const response = await fetch("/api/data");
23 const data = await response.json();
24 setParticipants(data.participants);
28 const handleLogin = async (e) => {
29 e.preventDefault();
30 const response = await fetch("/api/login", {
31 method: "POST",
32 headers: { "Content-Type": "application/json" },
49 const handleSubmit = async (e) => {
50 e.preventDefault();
51 const response = await fetch("/api/update", {
52 method: "POST",
53 headers: { "Content-Type": "application/json" },
58 setPoints("");
59 setNote("");
60 fetchData();
61 }
62 };
64 const handleReset = async () => {
65 if (window.confirm("Are you sure you want to reset all points?")) {
66 const response = await fetch("/api/reset", { method: "POST" });
67 if (response.ok) {
68 fetchData();
69 }
70 }
72
73 const handleExportCSV = async () => {
74 const response = await fetch("/api/export-csv");
75 const blob = await response.blob();
76 const url = window.URL.createObjectURL(blob);

SermonGPTAPImain.tsx2 matches

@mjweaver01•Updated 6 months ago
24 }
25 } catch (error) {
26 console.error("Error fetching sermons:", error);
27 return new Response(JSON.stringify([]), {
28 headers: { "Content-Type": "application/json" },
86 );
87 } catch (error) {
88 console.error("Error fetching sermons:", error);
89 return new Response(JSON.stringify([]), {
90 headers: { "Content-Type": "application/json" },

javascriptCoursemain.tsx1 match

@willthereader•Updated 6 months ago
48app.get("/javascriptCourse", javascriptCourse);
49app.get("/javascriptCourse/fizzBuzzTest", fizzBuzzTest);
50export default app.fetch;

blob_adminmain.tsx23 matches

@dakota•Updated 6 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));

randoDiscmain.tsx8 matches

@stevekrouse•Updated 6 months ago
77
78 useEffect(() => {
79 async function fetchReleases() {
80 try {
81 const response = await fetch("https://ashryanio-getallreleasesfromdiscogs.web.val.run");
82 if (!response.ok) {
83 throw new Error(`HTTP error! status: ${response.status}`);
84 }
85 const fetchedRecords = await response.json();
86 console.log(fetchedRecords);
87 if (!Array.isArray(fetchedRecords)) {
88 throw new Error("Received data is not an array");
89 }
90 const shuffledRecords = shuffleArray(fetchedRecords);
91 setRecords(shuffledRecords);
92 setIsLoading(false);
93 } catch (error) {
94 console.error("Failed to fetch releases:", error);
95 setError(error.message);
96 setIsLoading(false);
97 }
98 }
99 fetchReleases();
100 }, []);
101

Ms_Spanglermain.tsx2 matches

@arthrod•Updated 6 months ago
248
249 try {
250 const response = await fetch('/chat', {
251 method: 'POST',
252 headers: {
312});
313
314export default app.fetch;

gameplay_agentmain.tsx5 matches

@arthrod•Updated 6 months ago
7 * If you define your agent with {@link Connect4Agent} or {@link PokerAgent},
8 * then you can use {@link agentHandler} to create an http service that
9 * serves it. The service it creates is a standard fetch handler that can be
10 * used with a variety of different http server libraries.
11 *
48 * ]});
49 *
50 * Bun.serve({fetch: handler});
51 * ```
52 *
114
115/**
116 * Create standard fetch handler for an agent.
117 *
118 * Takes a list of agents and returns a handler that can be used to create an
119 * agent http endpoint.
120 * The handler implements the standard fetch interface and can be used with
121 * a variety of different http server libraries.
122 *
132 *
133 * @returns {(req: Request) => Promise<Response>} An async handler that can be
134 * used with an http server that supports the fetch interface.
135 */
136export function agentHandler<

whoIsHiringmain.tsx12 matches

@dxaginfo•Updated 6 months ago
61 }, [state.loading, state.hasMore]);
62
63 const fetchStories = async () => {
64 try {
65 const response = await fetch("/api/stories");
66 if (!response.ok) throw new Error("Failed to fetch dates");
67 const data = await response.json();
68 setStories(data);
70 }
71 catch (err) {
72 console.error("Error fetching stories:", err);
73 }
74 };
75
76 const fetchComments = async (query: string, story: string, page: number) => {
77 try {
78 dispatch({ type: "loading", value: true });
79 const response = await fetch(`/api/comments?query=${encodeURIComponent(query)}&story=${story}&page=${page}`);
80 if (!response.ok) throw new Error("Failed to fetch comments");
81 const data = await response.json();
82 setComments(prevComments => page === 1 ? data.hits : [...prevComments, ...data.hits]);
84 dispatch({ type: "loading", value: false });
85 } catch (err) {
86 console.error("Error fetching comments:", err);
87 dispatch({ type: "loading", value: false });
88 }
99 dispatch({ type: "hasMore", value: true });
100 dispatch({ type: "query", value: newQuery });
101 fetchComments(fullQuery, state.story, 1);
102 };
103
104 useEffect(() => {
105 fetchStories();
106
107 const handleScroll = () => {
122 : "";
123 const fullQuery = `${filtersQuery} ${state.query}`;
124 fetchComments(fullQuery, state.story, state.page);
125 }
126 }
391 tags: `comment, story_${story}`,
392 page: 0,
393 hitsPerPage: 100, // Fetch a moderate number of comments
394 });
395

lazyCookmain.tsx3 matches

@dxaginfo•Updated 6 months ago
20 setError("");
21 try {
22 const response = await fetch("/recipes", {
23 method: "POST",
24 headers: { "Content-Type": "application/json" },
32 }
33 } catch (err) {
34 setError("An error occurred while fetching recipes. Please try again.");
35 } finally {
36 setLoading(false);
339
340async function generateImage(recipeName: string): Promise<string> {
341 const response = await fetch(`https://maxm-imggenurl.web.val.run/${encodeURIComponent(recipeName)}`);
342 if (!response.ok) {
343 throw new Error(`Failed to generate image for ${recipeName}`);

FetchBasic2 file matches

@ther•Updated 12 hours ago

GithubPRFetcher

@andybak•Updated 3 days ago