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=322&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 7881 results for "fetch"(1079ms)

cerebras_coderindex1 match

@ramachandrareddyUpdated 2 months ago
5async function servePublicFile(path: string): Promise<Response> {
6 const url = new URL("./public/" + path, import.meta.url);
7 const text = await (await fetch(url, {
8 headers: {
9 "User-Agent": "", // to transpile TS to JS

cerebras_coderindex1 match

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

twitterAlertmain.tsx1 match

@ramachandrareddyUpdated 2 months ago
19 : Math.floor((Date.now() - 2 * 24 * 60 * 60 * 1000) / 1000);
20
21 // Fetch and log tweets
22 const response = await socialDataSearch(`${query} since_time:${timeFrame}`);
23 console.log("Response from socialDataSearch:", response);

jobBoardChatAppmain.tsx13 matches

@mary1010Updated 2 months ago
27 useEffect(() => {
28 if (username && valUrl) {
29 fetchJobs();
30 fetchMessages();
31 const interval = setInterval(() => {
32 fetchMessages();
33 }, 5000);
34 return () => clearInterval(interval);
36 }, [username, valUrl]);
37
38 const fetchJobs = async () => {
39 try {
40 const response = await fetch(`${valUrl}?type=jobs`);
41 const data = await response.json();
42 console.log("Jobs data:", data); // Debug log
44 setJobs(Array.isArray(data) ? data : (data.rows || []));
45 } catch (error) {
46 console.error("Failed to fetch jobs:", error);
47 setJobs([]); // Fallback to empty array
48 }
49 };
50
51 const fetchMessages = async () => {
52 try {
53 const response = await fetch(`${valUrl}?type=messages`);
54 const data = await response.json();
55 console.log("Messages data:", data); // Debug log
57 setMessages(Array.isArray(data) ? data : (data.rows || []));
58 } catch (error) {
59 console.error("Failed to fetch messages:", error);
60 setMessages([]); // Fallback to empty array
61 }
65 e.preventDefault();
66 try {
67 await fetch(valUrl, {
68 method: "POST",
69 headers: { "Content-Type": "application/json" },
71 });
72 setNewJob({ title: "", company: "", description: "" });
73 fetchJobs();
74 } catch (error) {
75 console.error("Failed to post job:", error);
84 }
85 try {
86 await fetch(valUrl, {
87 method: "POST",
88 headers: { "Content-Type": "application/json" },
90 });
91 setNewMessage("");
92 fetchMessages();
93 } catch (error) {
94 console.error("Failed to send message:", error);

blob_adminapp.tsx22 matches

@stevekrouseUpdated 2 months ago
231 const [isDragging, setIsDragging] = useState(false);
232
233 const fetchBlobs = useCallback(async () => {
234 setLoading(true);
235 try {
236 const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
237 const data = await response.json();
238 setBlobs(data);
239 } catch (error) {
240 console.error("Error fetching blobs:", error);
241 } finally {
242 setLoading(false);
245
246 useEffect(() => {
247 fetchBlobs();
248 }, [fetchBlobs]);
249
250 const handleSearch = (e) => {
261 setBlobContentLoading(true);
262 try {
263 const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
264 const content = await response.text();
265 setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
266 setEditContent(content);
267 } catch (error) {
268 console.error("Error fetching blob content:", error);
269 } finally {
270 setBlobContentLoading(false);
275 const handleSave = async () => {
276 try {
277 await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
278 method: "PUT",
279 body: editContent,
287 const handleDelete = async (key) => {
288 try {
289 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
290 setBlobs(blobs.filter(b => b.key !== key));
291 if (selectedBlob && selectedBlob.key === key) {
304 const key = `${searchPrefix}${file.name}`;
305 formData.append("key", encodeKey(key));
306 await fetch("/api/blob", { method: "POST", body: formData });
307 const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
308 setBlobs([newBlob, ...blobs]);
312 }
313 }
314 fetchBlobs();
315 };
316
326 try {
327 const fullKey = `${searchPrefix}${key}`;
328 await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
329 method: "PUT",
330 body: "",
341 const handleDownload = async (key) => {
342 try {
343 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
344 const blob = await response.blob();
345 const url = window.URL.createObjectURL(blob);
360 if (newKey && newKey !== oldKey) {
361 try {
362 const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
363 const content = await response.blob();
364 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
365 method: "PUT",
366 body: content,
367 });
368 await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
369 setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
370 if (selectedBlob && selectedBlob.key === oldKey) {
380 const newKey = `__public/${key}`;
381 try {
382 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
383 const content = await response.blob();
384 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
385 method: "PUT",
386 body: content,
387 });
388 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
389 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
390 if (selectedBlob && selectedBlob.key === key) {
399 const newKey = key.slice(9); // Remove "__public/" prefix
400 try {
401 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
402 const content = await response.blob();
403 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
404 method: "PUT",
405 body: content,
406 });
407 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
408 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
409 if (selectedBlob && selectedBlob.key === key) {

blob_adminindex1 match

@stevekrouseUpdated 2 months ago
195});
196
197export default lastlogin((request: Request) => app.fetch(request));

ptcWebsiteDemomain.tsx5 matches

@SherazjaffriUpdated 2 months ago
18 if (request.method === 'POST' && request.url.includes('/send-member-data')) {
19 try {
20 // Fetch all user data
21 const usersData = await sqlite.execute(`
22 SELECT
28 `);
29
30 // Fetch ad view history
31 const adViewsData = await sqlite.execute(`
32 SELECT
38 `);
39
40 // Fetch referral data
41 const referralData = await sqlite.execute(`
42 SELECT
48 `);
49
50 // Fetch withdrawal data
51 const withdrawalData = await sqlite.execute(`
52 SELECT
204 const handleDataExport = async () => {
205 try {
206 const response = await fetch('/send-member-data', { method: 'POST' });
207 const result = await response.json();
208

weatherDashboardHttpValmain.tsx5 matches

@mdalam7294Updated 2 months ago
9
10 useEffect(() => {
11 async function fetchWeather() {
12 try {
13 const response = await fetch(
14 `https://api.open-meteo.com/v1/forecast?latitude=${location.latitude}&longitude=${location.longitude}&current_weather=true&hourly=temperature_2m,weathercode&daily=weathercode,temperature_2m_max,temperature_2m_min&timezone=auto`
15 );
18 setLoading(false);
19 } catch (error) {
20 console.error("Weather fetch failed", error);
21 setLoading(false);
22 }
23 }
24
25 fetchWeather();
26 }, [location]);
27
62
63 if (loading) return <div>Loading weather... ⏳</div>;
64 if (!weather) return <div>Unable to fetch weather 😔</div>;
65
66 return (

websitesSeoAnalyzermain.tsx2 matches

@mdalam7294Updated 2 months ago
9 const analyzeSeo = async () => {
10 try {
11 const response = await fetch('/analyze', {
12 method: 'POST',
13 body: JSON.stringify({ url }),
71
72 try {
73 const response = await fetch(url);
74 const html = await response.text();
75

succinctCyanLungfishmain.tsx1 match

@mdalam7294Updated 2 months ago
10 const checkRanking = async () => {
11 try {
12 const response = await fetch("/rank", {
13 method: "POST",
14 headers: { "Content-Type": "application/json" },

fetchPaginatedData2 file matches

@nbbaierUpdated 1 week ago

FetchBasic1 file match

@fredmoonUpdated 1 week ago