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=91&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"(592ms)

OpenTownieBranchControl.tsx22 matches

@yakuzadave•Updated 1 week ago
30 const [showCreateBranch, setShowCreateBranch] = useState<boolean>(false);
31
32 // Fetch branches when project changes
33 useEffect(() => {
34 if (!projectId) return;
35
36 const fetchBranches = async () => {
37 setIsLoadingBranches(true);
38 try {
39 const response = await fetch(`/api/project-branches?projectId=${projectId}`, {
40 headers: {
41 "Authorization": `Bearer ${bearerToken}`,
44
45 if (!response.ok) {
46 throw new Error(`Failed to fetch branches: ${response.statusText}`);
47 }
48
49 const data = await response.json();
50 const fetchedBranches = data.branches || [];
51 setBranches(fetchedBranches);
52
53 // Check if the stored branchId is valid for this project
54 const storedBranchIsValid = fetchedBranches.some((branch: Branch) => branch.id === branchId);
55
56 // Only set a new branchId if there isn't a valid one already stored
57 if (!storedBranchIsValid && fetchedBranches.length > 0) {
58 // If branches are loaded and there's a "main" branch, select it by default
59 const mainBranch = fetchedBranches.find((branch: Branch) => branch.name === "main");
60 if (mainBranch) {
61 setBranchId(mainBranch.id);
63 } else {
64 // Otherwise select the first branch
65 setBranchId(fetchedBranches[0].id);
66 setSelectedBranchName(fetchedBranches[0].name);
67 }
68 } else if (storedBranchIsValid) {
69 // Set the selected branch name based on the stored branchId
70 const selectedBranch = fetchedBranches.find((branch: Branch) => branch.id === branchId);
71 if (selectedBranch) {
72 setSelectedBranchName(selectedBranch.name);
74 }
75 } catch (error) {
76 console.error("Error fetching branches:", error);
77 } finally {
78 setIsLoadingBranches(false);
80 };
81
82 fetchBranches();
83 }, [projectId, bearerToken, branchId, setBranchId]);
84
105 // Refresh the branches list
106 if (projectId) {
107 const fetchBranches = async () => {
108 try {
109 const response = await fetch(`/api/project-branches?projectId=${projectId}`, {
110 headers: {
111 "Authorization": `Bearer ${bearerToken}`,
114
115 if (!response.ok) {
116 throw new Error(`Failed to fetch branches: ${response.statusText}`);
117 }
118
119 const data = await response.json();
120 const fetchedBranches = data.branches || [];
121 setBranches(fetchedBranches);
122
123 // Update the selected branch name
124 const selectedBranch = fetchedBranches.find((branch: Branch) => branch.id === newBranchId);
125 if (selectedBranch) {
126 setSelectedBranchName(selectedBranch.name);
127 }
128 } catch (error) {
129 console.error("Error fetching branches:", error);
130 }
131 };
132
133 fetchBranches();
134 }
135 };

OpenTownieapi.ts3 matches

@yakuzadave•Updated 1 week ago
1// Fetch project files from the backend
2export async function fetchProjectFiles(
3 { bearerToken, projectId, branchId }: { bearerToken: string; projectId: string; branchId?: string },
4) {
9 }
10
11 const response = await fetch(url.toString(), {
12 headers: {
13 "Authorization": "Bearer " + bearerToken,

blob_adminmain.tsx1 match

@yakuzadave•Updated 1 week ago
195});
196
197export default lastlogin((request: Request) => app.fetch(request));

blob_adminapp.tsx22 matches

@yakuzadave•Updated 1 week 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) {

Jobs_aboard2main.tsx3 matches

@De_wise123•Updated 1 week ago
99 // Load existing jobs from server
100 useEffect(() => {
101 async function fetchJobs() {
102 try {
103 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
121 setJobs(result.rows);
122 } catch (error) {
123 console.error("Error fetching jobs:", error);
124 }
125 }
126
127 fetchJobs();
128 }, []);
129

pondiversemain2 matches

@iliazeus•Updated 1 week ago
1import addCreation from "./addCreation";
2import fetchCreations from "./fetchCreations";
3import getCreationImage from "./getCreationImage";
4import updateTable from "./updateTable";
13 return getCreationImage(req);
14 if (req.method == "GET" && url.pathname == "/creations")
15 return fetchCreations(req);
16 if (req.method == "POST" && url.pathname == "/updateTable")
17 return updateTable(req);

SamCronmain.tsx1 match

@sam254•Updated 1 week ago
3export default async function(interval: Interval) {
4 // Use open-meteo for free weather API
5 const response = await fetch(
6 "https://api.open-meteo.com/v1/forecast?latitude=-1.2921&longitude=36.8219&current_weather=true&temperature_unit=celsius&windspeed_unit=km/h&precipitation_unit=millimeters&timezone=Africa/Nairobi",
7 );

scintillatingLimeParakeetmain.tsx6 matches

@prezz_mwangi•Updated 1 week ago
21
22 useEffect(() => {
23 async function fetchFacts() {
24 const response = await fetch("/api/facts");
25 const data = await response.json();
26 setFacts(data);
27 }
28 fetchFacts();
29 }, []);
30
31 useEffect(() => {
32 async function fetchDailyFact() {
33 const response = await fetch("/api/daily-fact");
34 const data = await response.json();
35 setDailyFact(data);
36 }
37 fetchDailyFact();
38 }, []);
39

trustingYellowChickadeemain.tsx6 matches

@prezz_mwangi•Updated 1 week ago
21
22 useEffect(() => {
23 async function fetchFacts() {
24 const response = await fetch("/api/facts");
25 const data = await response.json();
26 setFacts(data);
27 }
28 fetchFacts();
29 }, []);
30
31 useEffect(() => {
32 async function fetchDailyFact() {
33 const response = await fetch("/api/daily-fact");
34 const data = await response.json();
35 setDailyFact(data);
36 }
37 fetchDailyFact();
38 }, []);
39

templateTwitterAlertmain.tsx1 match

@barbra_ke4627•Updated 1 week 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);

fetchPaginatedData2 file matches

@nbbaier•Updated 2 weeks ago

FetchBasic1 file match

@fredmoon•Updated 2 weeks ago