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?q=fetch&page=165&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 10273 results for "fetch"(788ms)

plantymain.tsx41 matches

@jonbo•Updated 1 week ago
149 const [showModal, setShowModal] = useState(false);
150
151 async function fetchLastWateredInternal() {
152 if (!syncId) return;
153 setIsLoading(true);
154 try {
155 const response = await fetch(`/api/${syncId}/last-watered`);
156 if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
157 const data = await response.json();
158 setLastWatered(data.lastWatered);
159 } catch (error) {
160 console.error("Error fetching last watered:", error);
161 setLastWatered(null); // Set to a default or error state
162 }
165
166 useEffect(() => {
167 fetchLastWateredInternal();
168 }, [syncId]);
169
220 <WatererSelectionModal
221 onClose={() => setShowModal(false)}
222 onWatered={fetchLastWateredInternal} // Pass the internal fetcher
223 />
224 )}
237 const [sortedWaterers, setSortedWaterers] = useState([]);
238
239 async function fetchWaterersInternal() {
240 if (!syncId) return;
241 try {
242 const response = await fetch(`/api/${syncId}/waterers`);
243 if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
244 const data = await response.json();
245 setWaterers(Array.isArray(data) ? data : []);
246 } catch (error) {
247 console.error("Error fetching waterers:", error);
248 setWaterers([]);
249 }
250 }
251
252 async function fetchRecentWaterersInternal() {
253 if (!syncId) return;
254 try {
255 const response = await fetch(`/api/${syncId}/history`);
256 if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
257 const data = await response.json();
264 setRecentWaterers(uniqueNames);
265 } catch (error) {
266 console.error("Error fetching recent waterers:", error);
267 setRecentWaterers([]);
268 }
303
304 useEffect(() => {
305 fetchWaterersInternal();
306 fetchRecentWaterersInternal();
307 }, [syncId]);
308
312
313 try {
314 await fetch(`/api/${syncId}/water`, {
315 method: "POST",
316 headers: { "Content-Type": "application/json" },
323 if (newWatererName.trim() && !selectedWaterer) {
324 // Add the new waterer to the list
325 await fetch(`/api/${syncId}/waterers`, {
326 method: "POST",
327 headers: { "Content-Type": "application/json" },
330 }
331
332 onWatered(); // This will call fetchLastWateredInternal in Plant component
333 onClose();
334 } catch (error) {
475 };
476
477 async function fetchDataInternal() {
478 if (!syncId) return;
479 setIsLoading(true);
481 try {
482 const [waterersResponse, historyResponse] = await Promise.all([
483 fetch(`/api/${syncId}/waterers`),
484 fetch(`/api/${syncId}/history`),
485 ]);
486 if (!waterersResponse.ok) throw new Error(`Waterers fetch error! status: ${waterersResponse.status}`);
487 if (!historyResponse.ok) throw new Error(`History fetch error! status: ${historyResponse.status}`);
488
489 const waterersData = await waterersResponse.json();
493 setHistory(Array.isArray(historyData) ? historyData : []);
494 } catch (error) {
495 console.error("Error fetching data for history:", error);
496 setWaterers([]);
497 setHistory([]);
502
503 useEffect(() => {
504 fetchDataInternal();
505 }, [syncId]);
506
510 setIsProcessing(true);
511 try {
512 await fetch(`/api/${syncId}/history/${entryId}`, { method: "DELETE" });
513 fetchDataInternal(); // Refresh
514 } catch (error) {
515 console.error("Error deleting history entry:", error);
673 const [isProcessing, setIsProcessing] = useState(false);
674
675 async function fetchWaterersInternal() {
676 if (!syncId) return;
677 setIsLoading(true);
678 setIsProcessing(true);
679 try {
680 const waterersResponse = await fetch(`/api/${syncId}/waterers`);
681 if (!waterersResponse.ok) throw new Error(`Waterers fetch error! status: ${waterersResponse.status}`);
682
683 const waterersData = await waterersResponse.json();
684 setWaterers(Array.isArray(waterersData) ? waterersData : []);
685 } catch (error) {
686 console.error("Error fetching waterers:", error);
687 setWaterers([]);
688 }
692
693 useEffect(() => {
694 fetchWaterersInternal();
695 }, [syncId]);
696
699 setIsProcessing(true);
700 try {
701 const response = await fetch(`/api/${syncId}/waterers`, {
702 method: "POST",
703 headers: { "Content-Type": "application/json" },
709 }
710 setNewWatererName("");
711 fetchWaterersInternal(); // Refresh waterers
712 } catch (error) {
713 console.error("Error adding waterer:", error);
723 setIsProcessing(true);
724 try {
725 await fetch(`/api/${syncId}/waterers/${watererId}`, {
726 method: "PUT",
727 headers: { "Content-Type": "application/json" },
728 body: JSON.stringify({ name: newName.trim() }),
729 });
730 fetchWaterersInternal(); // Refresh
731 } catch (error) {
732 console.error("Error renaming waterer:", error);
742 setIsProcessing(true);
743 try {
744 await fetch(`/api/${syncId}/waterers/${watererId}`, { method: "DELETE" });
745 fetchWaterersInternal(); // Refresh
746 } catch (error) {
747 console.error("Error deleting waterer:", error);
1034 });
1035
1036 self.addEventListener('fetch', event => {
1037 // For navigation requests, try network first, then cache
1038 if (event.request.mode === 'navigate') {
1039 event.respondWith(
1040 fetch(event.request)
1041 .then(response => {
1042 // Cache a copy of the response
1048 })
1049 .catch(() => {
1050 // If network fetch fails, fallback to cache
1051 return caches.match(event.request);
1052 })
1057 // For all other requests, try network, don't cache
1058 event.respondWith(
1059 fetch(event.request)
1060 .catch(() => caches.match(event.request))
1061 );
1085 [currentSyncId],
1086 );
1087 // Fetch the newly created row to ensure consistent data structure
1088 result = await sqlite.execute(
1089 `SELECT waterers, watering_log, last_watered_timestamp FROM instances WHERE sync_id = ?`,

cerebras_coder-BELLOYARONindex.ts1 match

@BELLOYARON•Updated 1 week ago
181
182 try {
183 const response = await fetch("/", {
184 method: "POST",
185 body: JSON.stringify({

acme-customsindex.tsx4 matches

@yawnxyz•Updated 1 week ago
68
69 async createWebCall(params) {
70 const response = await fetch(\`\${this.baseUrl}/call/web\`, {
71 method: 'POST',
72 headers: {
1180 if (!this.transcriptText || this.transcriptText.startsWith('Awaiting connection')) return;
1181 try {
1182 const res = await fetch("/extract-data", {
1183 method: "POST",
1184 headers: { "Content-Type": "application/json" },
1277});
1278
1279// Export app.fetch for Val Town, otherwise export app
1280export default (typeof Deno !== "undefined" && Deno.env.get("valtown"))
1281 ? app.fetch
1282 : app;

cerebras_coderindex.ts1 match

@BELLOYARON•Updated 1 week ago
181
182 try {
183 const response = await fetch("/", {
184 method: "POST",
185 body: JSON.stringify({

untitled-7712index.ts2 matches

@mayree•Updated 1 week ago
35 let html = await readFile("/frontend/index.html", import.meta.url);
36
37 // Fetch initial data
38 const jobs = await getJobs();
39 const messages = await getMessages(20); // Get last 20 messages
119
120// Export the Hono app
121export default app.fetch;

untitled-7712index.js17 matches

@mayree•Updated 1 week ago
49 renderMessages();
50 } else {
51 fetchJobs();
52 fetchMessages();
53 }
54
78
79 // Set up polling for new messages
80 setInterval(fetchMessages, 5000);
81}
82
83// API calls
84async function fetchJobs() {
85 try {
86 const response = await fetch('/api/jobs');
87 if (!response.ok) throw new Error('Failed to fetch jobs');
88
89 state.jobs = await response.json();
90 renderJobs();
91 } catch (error) {
92 console.error('Error fetching jobs:', error);
93 elements.jobsContainer.innerHTML = '<p class="text-red-500">Error loading jobs. Please try again.</p>';
94 }
95}
96
97async function fetchMessages(limit = 50) {
98 try {
99 const response = await fetch(`/api/messages?limit=${limit}`);
100 if (!response.ok) throw new Error('Failed to fetch messages');
101
102 const newMessages = await response.json();
108 }
109 } catch (error) {
110 console.error('Error fetching messages:', error);
111 if (elements.chatMessages.children.length === 0) {
112 elements.chatMessages.innerHTML = '<p class="text-red-500">Error loading messages. Please try again.</p>';
117async function createUser(username) {
118 try {
119 const response = await fetch('/api/users', {
120 method: 'POST',
121 headers: { 'Content-Type': 'application/json' },
136async function createJob(jobData) {
137 try {
138 const response = await fetch('/api/jobs', {
139 method: 'POST',
140 headers: { 'Content-Type': 'application/json' },
155async function sendMessage(content) {
156 try {
157 const response = await fetch('/api/messages', {
158 method: 'POST',
159 headers: { 'Content-Type': 'application/json' },
169 }
170
171 // Fetch latest messages after sending
172 fetchMessages();
173 return await response.json();
174 } catch (error) {
225 elements.jobForm.reset();
226 toggleModal(elements.jobModal, false);
227 fetchJobs();
228
229 // Announce the new job in chat

pass-genpassword-generator.ts5 matches

@dooooogie•Updated 1 week ago
1export default async function (req: Request) {
2 // Fetch a password from dinopass.com on the server side to avoid CORS issues
3 let dinoPassword = "";
4 try {
5 const response = await fetch('https://www.dinopass.com/password/simple');
6 dinoPassword = await response.text();
7 } catch (error) {
8 console.error('Error fetching from dinopass:', error);
9 dinoPassword = "quietbat76"; // Fallback example
10 }
245 button.innerHTML = '<span>Generating...</span>';
246
247 // Fetch from our own endpoint to avoid CORS issues
248 const response = await fetch(window.location.href);
249 const html = await response.text();
250

pass-genREADME.md1 match

@dooooogie•Updated 1 week ago
14## How It Works
15
161. When the "Generate Password" button is clicked, the app fetches a simple password from dinopass.com
172. It extracts two whole words from the response
183. It formats them as Word99Word! (with capitalized first letters)

untitled-2444index.ts2 matches

@all•Updated 1 week ago
163 } else {
164 // Use the server proxy
165 const response = await fetch("/api/process", {
166 method: "POST",
167 body: formData
727
728 try {
729 const response = await fetch("/api/detect-type", {
730 method: "POST",
731 headers: {

Afolabismain.tsx4 matches

@vawogbemi•Updated 1 week ago
110}
111
112const useAuthenticatedFetch = () => {
113 const { getToken } = useAuth();
114
116 const token = await getToken();
117
118 return await fetch(`https://www.thegluechat.com${endpoint}`, {
119 method: "POST",
120 body: JSON.stringify(data),
813 setIsLoading(true);
814 // Reverse geocode the coordinates to get an address
815 const response = await fetch(
816 `https://maps.googleapis.com/maps/api/geocode/json?latlng=${position.coords.latitude},${position.coords.longitude}&key=AIzaSyAOtUMb5jLTjTVM7iKzIx2SJ3HgMKNcM7U`,
817 );
1230});
1231
1232export default app.fetch;

agentplex-deal-flow-email-fetch1 file match

@anandvc•Updated 5 days ago

proxyFetch2 file matches

@vidar•Updated 1 week ago