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=49&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 8994 results for "fetch"(723ms)

cerebras_codermain.tsx1 match

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

ValTown-Package-Trackerindex.html2 matches

@jhiller•Updated 3 days ago
151 async function loadDevices() {
152 try {
153 const response = await fetch('/api/devices');
154 const devices = await response.json();
155
177 const url = deviceId ? `/api/locations?deviceId=${deviceId}` : '/api/locations';
178
179 const response = await fetch(url);
180 locations = await response.json();
181

ValTown-Package-Trackerindex.ts11 matches

@jhiller•Updated 3 days ago
188// API endpoint to get location history
189app.get("/api/locations", async (c) => {
190 console.log("[API] Fetching location history");
191
192 try {
195 console.log(`[API] Filtering locations by device ID: ${deviceId}`);
196 } else {
197 console.log("[API] Fetching all locations (no device filter)");
198 }
199 const { rows } = await getLocationHistory(deviceId);
208
209 } catch (error) {
210 console.error("[API] Error fetching location history:", error);
211 return c.json({
212 error: "Database error",
213 details: "Failed to fetch location history",
214 message: error.message
215 }, 500);
221 try {
222 const idParam = c.req.param("id");
223 console.log(`[API] Fetching location with ID: ${idParam}`);
224
225 const id = parseInt(idParam);
244 return c.json(location);
245 } catch (error) {
246 console.error(`[API] Error fetching location:`, error);
247 return c.json({
248 error: "Database error",
249 details: "Failed to fetch location data",
250 message: error.message
251 }, 500);
255// API endpoint to get list of devices
256app.get("/api/devices", async (c) => {
257 console.log("[API] Fetching device list");
258
259 try {
262 return c.json(devices.rows);
263 } catch (error) {
264 console.error("[API] Error fetching devices:", error);
265 return c.json({
266 error: "Database error",
267 details: "Failed to fetch device list",
268 message: error.message
269 }, 500);
272
273// Export the Hono app for HTTP vals
274export default app.fetch;

TownieuseProject.tsx5 matches

@devdoshi•Updated 3 days ago
9 const [error, setError] = useState(null);
10
11 const fetchData = async () => {
12 try {
13 const projectEndpoint = new URL(PROJECT_ENDPOINT, window.location.origin);
17 if (branchId) filesEndpoint.searchParams.append("branchId", branchId);
18
19 const { project } = await fetch(projectEndpoint)
20 .then(res => res.json());
21 const { files } = await fetch(filesEndpoint)
22 .then(res => res.json());
23
34 useEffect(() => {
35 if (!projectId) return;
36 fetchData();
37 }, [projectId, branchId]);
38
39 return { data, loading, error, refetch: fetchData };
40}
41

TownieuseProjects.tsx4 matches

@devdoshi•Updated 3 days ago
8 const [error, setError] = useState(null);
9
10 const fetchData = async () => {
11 try {
12 const res = await fetch(ENDPOINT)
13 const data = await res.json();
14 if (!res.ok) {
32
33 useEffect(() => {
34 fetchData();
35 }, []);
36
37 return { data, loading, error, refetch: fetchData };
38}
39

TownieuseCreateProject.tsx1 match

@devdoshi•Updated 3 days ago
16 setError(null);
17 try {
18 const res = await fetch(ENDPOINT, {
19 method: "POST",
20 headers: {

TownieuseCreateBranch.tsx1 match

@devdoshi•Updated 3 days ago
14 setData(null);
15 setError(null);
16 const res = await fetch(ENDPOINT, {
17 method: "POST",
18 body: JSON.stringify({

TownieuseBranches.tsx4 matches

@devdoshi•Updated 3 days ago
7 const [loading, setLoading] = useState(true);
8
9 const fetchData = async () => {
10 const endpoint = new URL(ENDPOINT, window.location.origin);
11 endpoint.searchParams.append("projectId", projectId);
12
13 const res = await fetch(endpoint)
14 .then(res => res.json());
15 setData(res.branches); // todo error handling
19 useEffect(() => {
20 if (!projectId) return;
21 fetchData();
22 }, [projectId]);
23
24 return { data, loading, refetch: fetchData };
25}
26

TownieTODOs.md1 match

@devdoshi•Updated 3 days ago
47<!--
48
49- [x] refetch project data on create/etc
50- [x] Loading favicon
51- [x] Ensure main branch is default selected

Townietext-editor.ts1 match

@devdoshi•Updated 3 days ago
136 let type_: "file" | "http" | "script";
137 if (path.includes("backend/index.ts")) type_ = "http";
138 if (file_text?.includes("export default app.fetch")) type_ = "http";
139 if ([".ts", ".tsx", ".js", ".jsx"].some(ext => path.endsWith(ext))) {
140 type_ = "script";

TAC_FetchBasic2 file matches

@A7_OMC•Updated 3 hours ago

hn-fetch1 file match

@matija•Updated 5 hours ago