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/$%7Bart_info.art.src%7D?q=fetch&page=100&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 8614 results for "fetch"(1662ms)

OpenTownieChat.tsx1 match

@charmaine•Updated 2 weeks ago
29 const [isDragging, setIsDragging] = useState(false);
30
31 // Use custom hook to fetch project files
32 const {
33 projectFiles,

OpenTownieBranchControl.tsx22 matches

@charmaine•Updated 2 weeks 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

@charmaine•Updated 2 weeks 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,

Staff_Chatroommain.tsx9 matches

@editrust123•Updated 2 weeks ago
35 const [isLoggedIn, setIsLoggedIn] = useState(false);
36
37 // Fetch messages periodically
38 useEffect(() => {
39 if (isLoggedIn) {
40 const fetchMessages = async () => {
41 try {
42 const response = await fetch('/messages');
43 const result = await response.json();
44 if (result.ok) {
46 }
47 } catch (error) {
48 console.error('Failed to fetch messages');
49 }
50 };
51
52 fetchMessages();
53 const intervalId = setInterval(fetchMessages, 5000);
54 return () => clearInterval(intervalId);
55 }
58 const handleRegister = async () => {
59 try {
60 const response = await fetch('/register', {
61 method: 'POST',
62 headers: { 'Content-Type': 'application/json' },
82 const handleLogin = async () => {
83 try {
84 const response = await fetch('/login', {
85 method: 'POST',
86 headers: { 'Content-Type': 'application/json' },
113
114 try {
115 const response = await fetch('/send-message', {
116 method: 'POST',
117 headers: { 'Content-Type': 'application/json' },

JaanWebsiteStatusmonitor2 matches

@shafogrin•Updated 2 weeks ago
15 const start = performance.now();
16 try {
17 res = await fetch(url);
18 end = performance.now();
19 status = res.status;
25 } catch (e) {
26 end = performance.now();
27 reason = `couldn't fetch: ${e}`;
28 ok = false;
29 }

Projectmain.tsx4 matches

@ladyflo0600•Updated 2 weeks ago
40 });
41
42 // Fetch products on component mount
43 useEffect(() => {
44 fetch(import.meta.url, { method: 'GET' })
45 .then(response => response.json())
46 .then(data => setProducts(data.products));
82 e.preventDefault();
83 try {
84 const response = await fetch(import.meta.url, {
85 method: 'POST',
86 headers: { 'Content-Type': 'application/json' },
296 }
297
298 // Handle GET request to fetch products
299 if (request.method === 'GET') {
300 const productsResult = await sqlite.execute(`SELECT * FROM ${KEY}_products`);

timeTrackerAppmain.tsx8 matches

@Judith_123•Updated 2 weeks ago
12 useEffect(() => {
13 const timer = setInterval(() => setCurrentTime(new Date()), 1000);
14 fetchRecentRecords();
15 return () => clearInterval(timer);
16 }, []);
17
18 const fetchRecentRecords = async () => {
19 try {
20 const response = await fetch('/recent-records');
21 const records = await response.json();
22 setRecentRecords(records);
23 } catch (error) {
24 console.error('Failed to fetch recent records', error);
25 }
26 };
33
34 try {
35 const response = await fetch('/clock-action', {
36 method: 'POST',
37 headers: {
43 setStatus(result.status);
44 setLastClockIn(result.timestamp);
45 fetchRecentRecords();
46 } catch (error) {
47 console.error('Clock action failed', error);
51 const handleExportToExcel = async () => {
52 try {
53 const response = await fetch('/export-excel');
54 const blob = await response.blob();
55 const url = window.URL.createObjectURL(blob);
173 }
174
175 // Fetch recent records
176 if (request.method === 'GET' && new URL(request.url).pathname === '/recent-records') {
177 const recentRecords = await sqlite.execute(`

englishways_migratedmain.tsx7 matches

@maryamdorgam•Updated 2 weeks ago
20
21 useEffect(() => {
22 fetch('/username')
23 .then(response => response.text())
24 .then(name => {
25 if (name) {
26 setUsername(name);
27 fetchArticles();
28 }
29 });
30 }, []);
31
32 const fetchArticles = () => {
33 fetch('/articles')
34 .then(response => response.json())
35 .then(data => setArticles(data));
46 const handleUsernameSubmit = () => {
47 if (editingUsername.trim()) {
48 fetch('/username', {
49 method: 'POST',
50 body: editingUsername.trim()
54 setUsername(name);
55 setShowWelcome(false);
56 fetchArticles();
57 });
58 }
66 const handleUsernameSave = () => {
67 if (editingUsername.trim()) {
68 fetch('/username', {
69 method: 'POST',
70 body: editingUsername.trim()

shiftSchedulermain.tsx7 matches

@icing•Updated 2 weeks ago
13
14 useEffect(() => {
15 fetchShifts();
16 }, []);
17
18 const fetchShifts = async () => {
19 const response = await fetch("/shifts");
20 const data = await response.json();
21 setShifts(data);
29 const addShift = async (e) => {
30 e.preventDefault();
31 await fetch("/shifts", {
32 method: "POST",
33 headers: { "Content-Type": "application/json" },
34 body: JSON.stringify(newShift)
35 });
36 fetchShifts();
37 setNewShift({ employeeName: "", date: "", startTime: "", endTime: "" });
38 };
39
40 const deleteShift = async (id) => {
41 await fetch(`/shifts/${id}`, { method: "DELETE" });
42 fetchShifts();
43 };
44

globalCareIndustriesWebsitemain.tsx1 match

@Judith_123•Updated 2 weeks ago
116
117 try {
118 const response = await fetch("/submit-contact", {
119 method: "POST",
120 headers: {

fetchPaginatedData2 file matches

@nbbaier•Updated 2 weeks ago

FetchBasic1 file match

@fredmoon•Updated 3 weeks ago