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=469&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 8149 results for "fetch"(1495ms)

cerebras_codermain.tsx7 matches

@adnane007al•Updated 4 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({

blueskyAlertmain.tsx1 match

@eseidel•Updated 4 months ago
7const agent = new AtpAgent({
8 service: "https://public.api.bsky.app/",
9 // fetch, ideally we'd use our @std/fetch proxy here but that doesn't work and I don't know why
10});
11

simpleChatAPImain.tsx5 matches

@haeliyan•Updated 4 months ago
14
15 useEffect(() => {
16 fetchMessages();
17 }, []);
18
19 const fetchMessages = async () => {
20 const response = await fetch("/messages");
21 const data = await response.json();
22 setMessages(data);
30 }
31 localStorage.setItem("chatUsername", username);
32 await fetch("/messages", {
33 method: "POST",
34 headers: { "Content-Type": "application/json" },
39 });
40 setNewMessage("");
41 fetchMessages();
42 };
43

SermonGPTUImain.tsx9 matches

@manyone•Updated 4 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 4 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 4 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 4 months ago
48app.get("/javascriptCourse", javascriptCourse);
49app.get("/javascriptCourse/fizzBuzzTest", fizzBuzzTest);
50export default app.fetch;

blob_adminmain.tsx23 matches

@dakota•Updated 4 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 4 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 5 months ago
248
249 try {
250 const response = await fetch('/chat', {
251 method: 'POST',
252 headers: {
312});
313
314export default app.fetch;

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago