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/image-url.jpg%20%22Optional%20title%22?q=fetch&page=945&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 14351 results for "fetch"(6691ms)

reactHonoStarterindex.ts2 matches

@agree•Updated 3 months ago
24});
25
26// HTTP vals expect an exported "fetch handler"
27// This is how you "run the server" in Val Town with Hono
28export default app.fetch;

expSumOfTheDaymain.tsx2 matches

@charmaine•Updated 3 months ago
80
81 React.useEffect(() => {
82 const fetchSvg = () => {
83 const month = currentDate.getMonth() + 1;
84 const date = currentDate.getDate();
88 };
89
90 fetchSvg();
91
92 const timer = setInterval(() => {

fiberplaneHonoStartermain.tsx1 match

@boots•Updated 3 months ago
58});
59
60export default app.fetch;

iiif44tumain.tsx4 matches

@sammeltassen•Updated 3 months ago
5const iiifBaseUrl = "https://data.4tu.nl/iiif/v3/";
6
7async function fetchJson(url: string, token: string | null = null) {
8 const headers = new Headers();
9 if (token) {
10 headers.append("Authorization", `token ${token}`);
11 }
12 return fetch(url, { headers }).then(resp => resp.ok ? resp.json() : null);
13}
14
71 }
72 const token = params.get("token");
73 const metadata = await fetchJson((token ? privateApiUrl : publicApiUrl) + "/" + datasetUuid, token);
74 // return Response.json(metadata);
75 if (!metadata) {
78 const images = await Promise.all(
79 metadata.files.map((i: any) =>
80 fetchJson(iiifBaseUrl + i.uuid + "/info.json").then(resp => resp ? { ...resp, meta: i } : null)
81 ),
82 );

aBeautifulMindindex.ts2 matches

@charmaine•Updated 3 months 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;

twitterAlertmain.tsx3 matches

@Akash11•Updated 3 months ago
8
9 useEffect(() => {
10 // Fetch initial balance when component loads
11 fetch('/balance')
12 .then(response => response.json())
13 .then(data => setBalance(data.balance));
16 const handleClick = async () => {
17 try {
18 const response = await fetch('/earn', { method: 'POST' });
19 const data = await response.json();
20 setBalance(data.balance);

dailySlackRoundupmain.tsx2 matches

@Zxnxn•Updated 3 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { getDayName } from "https://esm.town/v/stevekrouse/getDayName?v=2";
3import process from "node:process";
4
5export const dailySlackRoundup = (async () => {
6 const res = await fetch(process.env.BRAINBOT_WEBHOOK_URL, {
7 method: "POST",
8 body: JSON.stringify({

blob_adminmain.tsx23 matches

@yutae•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) {
838});
839
840export default lastlogin((request: Request) => app.fetch(request));

wikidataredirectormain.tsx5 matches

@g•Updated 3 months ago
7 * 3. Automatically redirect to the first website if only one exists
8 *
9 * Uses Wikidata's EntityData API to fetch website information
10 */
11import { Hono } from 'npm:hono';
85
86 try {
87 const res = await fetch(`https://www.wikidata.org/wiki/Special:EntityData/${qid}.json?flavor=simple`);
88 const data = await res.json();
89
140
141 } catch (error) {
142 console.error('Wikidata fetch error:', error);
143 return c.text('Error fetching Wikidata information', 500);
144 }
145});
146
147export default app.fetch;

ValueAwardmain.tsx12 matches

@Bernard_Lori•Updated 3 months ago
77
78 useEffect(() => {
79 fetchHighFives();
80 if (isAdmin) {
81 fetchAnalytics();
82 }
83 }, [isAdmin]);
91 }, [employeeSearch]);
92
93 const fetchHighFives = async () => {
94 const response = await fetch('/api/highfives');
95 const data = await response.json();
96 setHighFives(data);
97 };
98
99 const fetchAnalytics = async () => {
100 const response = await fetch('/api/analytics');
101 const data = await response.json();
102 setAnalytics(data);
117 if (isAdminUser) {
118 setIsAdmin(true);
119 fetchAnalytics();
120 } else {
121 alert('Invalid admin credentials');
125 data.awardDate = new Date().toISOString().split('T')[0];
126
127 const response = await fetch('/api/highfives', {
128 method: 'POST',
129 headers: {
136 alert('High five submitted successfully!');
137 event.target.reset();
138 fetchHighFives();
139 } else {
140 alert('Error submitting high five. Please try again.');
144
145 const handleDownloadCSV = async () => {
146 const response = await fetch('/api/download-csv');
147 if (response.ok) {
148 const blob = await response.blob();
162 const handleDeleteAnalytics = async () => {
163 if (window.confirm('Are you sure you want to delete all recorded data and start fresh? This action cannot be undone.')) {
164 const response = await fetch('/api/delete-analytics', { method: 'POST' });
165 if (response.ok) {
166 alert('All recorded data has been deleted. Analytics will start fresh from now.');
167 fetchAnalytics();
168 } else {
169 alert('Error deleting analytics data. Please try again.');

FetchBasic2 file matches

@ther•Updated 1 week ago

GithubPRFetcher

@andybak•Updated 1 week ago