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=465&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 8143 results for "fetch"(877ms)

blob_adminmain.tsx23 matches

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

weatherGPTmain.tsx1 match

@rohanchoudhary15•Updated 4 months ago
4let location = "brooklyn ny";
5let lang = "en";
6const weather = await fetch(
7 `https://wttr.in/${location}?lang=${lang}&format=j1`,
8).then(r => r.json());

devstatsmain.tsx3 matches

@carburo•Updated 4 months ago
130 return c.json(await getRows())
131 } catch (error) {
132 console.error("Error fetching data:", error)
133 return c.text("Error fetching data", 500)
134 }
135})
170 `)
171
172 return app.fetch(req)
173}

randoDiscmain.tsx20 matches

@ashryanio•Updated 4 months ago
121 const [moveDirection, setMoveDirection] = useState(null);
122 const [hasInteracted, setHasInteracted] = useState(false);
123 const fetchedRecords = useRef(new Set());
124
125 useEffect(() => {
126 async function fetchReleases() {
127 try {
128 const response = await fetch("https://ashryanio-getallreleasesfromdiscogs.web.val.run");
129 if (!response.ok) {
130 throw new Error(`HTTP error! status: ${response.status}`);
131 }
132 const fetchedRecords = await response.json();
133 if (!Array.isArray(fetchedRecords)) {
134 throw new Error("Received data is not an array");
135 }
136
137 const shuffledRecords = shuffleArray(fetchedRecords);
138 setRecords(shuffledRecords);
139 setIsLoading(false);
140 } catch (error) {
141 console.error("Failed to fetch releases:", error);
142 setError(error.message);
143 setIsLoading(false);
144 }
145 }
146 fetchReleases();
147 }, []);
148
149 // Fetch release year for the current record
150 useEffect(() => {
151 async function fetchReleaseYear() {
152 if (records.length === 0) return;
153
154 const currentRecord = records[currentRecordIndex];
155 if (!currentRecord || fetchedRecords.current.has(currentRecord.basic_information.master_id)) {
156 return; // Skip if already fetched
157 }
158
159 try {
160 console.log("Fetching release year for:", currentRecord);
161 const response = await fetch(
162 `https://ashryanio-getallreleasesfromdiscogs.web.val.run/masters?id=${currentRecord.basic_information.master_id}`,
163 );
164 if (!response.ok) {
165 throw new Error(`Failed to fetch release year: ${response.status}`);
166 }
167 const data = await response.json();
168 console.log("Fetched data:", data);
169
170 // Mark as fetched
171 fetchedRecords.current.add(currentRecord.basic_information.master_id);
172
173 // Update the record
180 );
181 } catch (error) {
182 console.error("Error fetching release year:", error);
183 }
184 }
185
186 fetchReleaseYear();
187 }, [currentRecordIndex, records.length]);
188

cerebras_codermain.tsx4 matches

@nickstefen•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
146
147 try {
148 const response = await fetch("/", {
149 method: "POST",
150 body: JSON.stringify({

FetchBasicREADME.md2 matches

@thesagrotan•Updated 4 months ago
1# Framer Fetch: Basic
2
3A basic example of an API endpoint to use with Framer Fetch. CORS headers are permissive by default on Val Town, so no need to set them.

rijksmain.tsx7 matches

@sammeltassen•Updated 4 months ago
53 const imageApiEndpoint = record?.["rdf:RDF"]?.["svcs:Service"]?.[0]?.$?.["rdf:about"];
54 if (imageApiEndpoint) {
55 return fetch(imageApiEndpoint)
56 .then(resp => resp.json())
57 .catch((err) => console.log(`Error fetching Image Information from ${imageApiEndpoint}`, err));
58 } else return null;
59}
62 const uri = part.$["rdf:resource"];
63 const id = uri.split("/").pop();
64 return fetchJson(id)
65 .then(getImageInformation)
66 .catch((err) => console.log(`Error fetching more images from ${id}`, err));
67}
68
142}
143
144async function fetchJson(id: string) {
145 const headers = new Headers([
146 ["Accept-Profile", "edm"],
149 const url = new URL(apiBase + id);
150 const parser = new Parser();
151 return fetch(url, { headers })
152 .then(resp => resp.text())
153 .then(text => parser.parseStringPromise(text))
164 });
165 }
166 const resp = await fetchJson(id.toString());
167 if (resp.error || params.get("format") === "edm") {
168 return Response.json(resp);

inspiringLavenderTakinmain.tsx4 matches

@stevekrouse•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
146
147 try {
148 const response = await fetch("/", {
149 method: "POST",
150 body: JSON.stringify({

slackScoutmain.tsx8 matches

@kamath•Updated 4 months ago
20 for (const topic of KEYWORDS) {
21 const results = await Promise.allSettled([
22 fetchHackerNewsResults(topic),
23 fetchTwitterResults(topic),
24 fetchRedditResults(topic),
25 ]);
26
49}
50
51// Fetch Hacker news, Twitter, and Reddit results
52async function fetchHackerNewsResults(topic: string): Promise<Website[]> {
53 return hackerNewsSearch({
54 query: topic,
58}
59
60async function fetchTwitterResults(topic: string): Promise<Website[]> {
61 return twitterSearch({
62 query: topic,
67}
68
69async function fetchRedditResults(topic: string): Promise<Website[]> {
70 return redditSearch({ query: topic });
71}
84 }
85
86 const response = await fetch(slackWebhookUrl, {
87 method: "POST",
88 headers: { "Content-Type": "application/json" },

interview_practicemain.tsx1 match

@spinningideas•Updated 4 months ago
90
91 try {
92 const response = await fetch("/ask", {
93 method: "POST",
94 headers: {

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago