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=424&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 8457 results for "fetch"(929ms)

CRMmain.tsx20 matches

@stevekrouse•Updated 3 months ago
10 e.preventDefault();
11 try {
12 const response = await fetch("/login", {
13 method: "POST",
14 headers: { "Content-Type": "application/json" },
58 const [tagInput, setTagInput] = useState("");
59
60 // Fetch previous customer details when email changes
61 useEffect(() => {
62 const fetchCustomerDetails = async () => {
63 if (!email) return;
64
65 try {
66 const response = await fetch(`/get-customer-details?email=${encodeURIComponent(email)}`);
67 if (response.ok) {
68 const customerDetails = await response.json();
73 }
74 } catch (error) {
75 console.error("Error fetching customer details:", error);
76 }
77 };
78
79 fetchCustomerDetails();
80 }, [email]);
81
138 e.preventDefault();
139 try {
140 const response = await fetch("/add-interaction", {
141 method: "POST",
142 headers: { "Content-Type": "application/json" },
250 const [uniqueCustomerCount, setUniqueCustomerCount] = useState(0);
251
252 const fetchUniqueCustomerCount = async () => {
253 try {
254 const response = await fetch("/get-unique-customer-count");
255 const data = await response.json();
256 setUniqueCustomerCount(data.count);
257 } catch (error) {
258 console.error("Error fetching unique customer count:", error);
259 }
260 };
261
262 useEffect(() => {
263 fetchInteractions();
264 fetchUniqueCustomerCount();
265 }, [currentPage, selectedTags]);
266
281 const handleDeleteInteraction = async (id) => {
282 try {
283 const response = await fetch("/delete-interaction", {
284 method: "DELETE",
285 headers: { "Content-Type": "application/json" },
288
289 if (response.ok) {
290 fetchInteractions();
291 }
292 } catch (error) {
303 };
304
305 const fetchInteractions = async () => {
306 try {
307 const response = await fetch(`/get-interactions?page=${currentPage}`);
308 const data = await response.json();
309
336 if (selectedTags.length > 0) {
337 // Need to get total count of filtered interactions from server
338 const filteredCountResponse = await fetch(`/get-filtered-count?tags=${selectedTags.join(",")}`);
339 const filteredCountData = await filteredCountResponse.json();
340 setTotalInteractions(filteredCountData.count);
343 }
344 } catch (error) {
345 console.error("Error fetching interactions:", error);
346 }
347 };
348
349 useEffect(() => {
350 fetchInteractions();
351 }, [currentPage, selectedTags]);
352
481 const checkAuth = async () => {
482 try {
483 const response = await fetch("/check-auth");
484 const data = await response.json();
485 setIsAuthenticated(data.authenticated);

TodoListmain.tsx9 matches

@vyatka•Updated 3 months ago
40
41 useEffect(() => {
42 fetchTasks();
43 loadUserPreferences();
44 }, []);
72 }
73
74 async function fetchTasks() {
75 try {
76 const response = await fetch("/get-tasks");
77 const data = await response.json();
78 setTaskLists(data);
79 } catch (error) {
80 console.error("Error fetching tasks", error);
81 }
82 }
86
87 try {
88 const response = await fetch("/add-task", {
89 method: "POST",
90 headers: { "Content-Type": "application/json" },
107
108 try {
109 const response = await fetch("/move-task", {
110 method: "POST",
111 headers: { "Content-Type": "application/json" },
125 async function removeTask(taskId, column) {
126 try {
127 const response = await fetch("/delete-task", {
128 method: "POST",
129 headers: { "Content-Type": "application/json" },
142
143 try {
144 const response = await fetch("/move-task", {
145 method: "POST",
146 headers: { "Content-Type": "application/json" },
174 if (!editedTaskText.trim() || !taskBeingEdited) return;
175 try {
176 const response = await fetch("/update-task", {
177 method: "POST",
178 headers: { "Content-Type": "application/json" },

fetchEventsmain.tsx4 matches

@richardwu9•Updated 3 months ago
19
20 try {
21 // Fetch events from Luma API
22 const response = await fetch(apiUrl, {
23 method: "GET",
24 headers: apiHeaders, // Use correct API headers here
40 } catch (error) {
41 // Log the error and return a 500 error response
42 console.error("Error fetching events:", error);
43 return new Response(
44 JSON.stringify({ error: "Failed to fetch events", details: error.message }),
45 { status: 500, headers },
46 );

terrificCoralMolemain.tsx3 matches

@richardwu9•Updated 3 months ago
1export async function fetchEvents() {
2 const url = "https://api.lu.ma/public/v1/calendar/list-events";
3 const headers = {
7
8 try {
9 const response = await fetch(url, { method: "GET", headers });
10 const data = await response.json();
11 return data; // Return the API response
12 } catch (error) {
13 return { error: "Failed to fetch events", details: error.message };
14 }
15}

captchamain.tsx1 match

@loading•Updated 3 months ago
136 async function submitScore() {
137 try {
138 const response = await fetch("/submit-highscore", {
139 method: "POST",
140 headers: {

sweetBlackHaremain.tsx1 match

@imnk•Updated 3 months ago
249
250 try {
251 const response = await fetch('/analyze', {
252 method: 'POST',
253 body: formData

blob_adminmain.tsx23 matches

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

cerebras_codermain.tsx1 match

@telvideo•Updated 3 months ago
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({

tasks_test1main.tsx13 matches

@arfan•Updated 3 months ago
162
163 React.useEffect(() => {
164 fetchTasks();
165 }, []);
166
167 const fetchTasks = async () => {
168 const response = await fetch('/api/tasks');
169 const fetchedTasks = await response.json();
170 setTasks(fetchedTasks);
171 };
172
188 if (newTask.text.trim() && newTask.dueDate) {
189 try {
190 const response = await fetch('/api/tasks', {
191 method: 'POST',
192 headers: { 'Content-Type': 'application/json' },
196 setNewTask({ text: '', done: false, dueDate: DEFAULT_DATE });
197 setIsAddTaskModalOpen(false);
198 fetchTasks();
199 }
200 } catch (error) {
206 const handleDeleteTask = async (taskId) => {
207 try {
208 const response = await fetch(`/api/tasks/${taskId}`, { method: 'DELETE' });
209 if (response.ok) {
210 fetchTasks();
211 }
212 } catch (error) {
224 if (taskToEdit.text.trim() && taskToEdit.dueDate) {
225 try {
226 const response = await fetch(`/api/tasks/${taskToEdit.id}`, {
227 method: 'PUT',
228 headers: { 'Content-Type': 'application/json' },
232 setIsEditTaskModalOpen(false);
233 setTaskToEdit(null);
234 fetchTasks();
235 }
236 } catch (error) {
242 const handleToggleTaskCompletion = async (taskId, done) => {
243 try {
244 const response = await fetch(`/api/tasks/${taskId}`, {
245 method: 'PATCH',
246 headers: { 'Content-Type': 'application/json' },
248 });
249 if (response.ok) {
250 fetchTasks();
251 }
252 } catch (error) {

helpfulTealTapirmain.tsx1 match

@vishu44•Updated 3 months ago
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({

fetchPaginatedData2 file matches

@nbbaier•Updated 2 weeks ago

FetchBasic1 file match

@fredmoon•Updated 2 weeks ago