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=86&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 8298 results for "fetch"(504ms)

valProfilePageValGridItem.tsx7 matches

@dcm31•Updated 1 week ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React, { useState, useEffect } from "https://esm.sh/react@18.2.0";
3import { fetchMoiConfig } from "../utils/moiConfig.tsx";
4
5interface Val {
45 };
46
47 // Attempt to fetch moi.md for this val if it doesn't have an image
48 useEffect(() => {
49 const fetchMoiData = async () => {
50 // Only try to fetch moi.md if there's no image_url
51 if (!val.image_url) {
52 try {
59 // Construct the base URL for the val/project
60 const baseUrl = urlParts.slice(0, xIndex + 3).join('/');
61 const config = await fetchMoiConfig(baseUrl);
62 setMoiConfig(config);
63 }
64 } catch (error) {
65 console.error("Error fetching moi.md for val:", error);
66 }
67 }
68 };
69
70 fetchMoiData();
71 }, [val.url, val.image_url]);
72

valProfilePageUserProfile.tsx8 matches

@dcm31•Updated 1 week ago
2import React, { useState, useEffect } from "https://esm.sh/react@18.2.0";
3import { ValGrid } from "./ValGrid.tsx";
4import { fetchMoiConfig, getProfileImageUrl } from "../utils/moiConfig.tsx";
5
6interface UserProfileProps {
57
58 useEffect(() => {
59 const fetchUserProfile = async () => {
60 setLoading(true);
61 setError(null);
62
63 try {
64 // Fetch both user profile data and moi config in parallel
65 const [profileResponse, config] = await Promise.all([
66 fetch(`/api/profile/${username}?page=${currentPage}`),
67 fetchMoiConfig(`https://www.val.town/x/${username}/`)
68 ]);
69
72
73 if (!profileResponse.ok) {
74 throw new Error(`Failed to fetch profile data: ${profileResponse.statusText}`);
75 }
76
97 setProfileData(data);
98 } catch (err) {
99 console.error("Error fetching profile:", err);
100 setError(err instanceof Error ? err.message : "Unknown error occurred");
101 } finally {
104 };
105
106 fetchUserProfile();
107 }, [username, currentPage]);
108

valProfilePagemoiConfig.tsx5 matches

@dcm31•Updated 1 week ago
78
79/**
80 * Fetch and parse moi.md for a project
81 * Returns the parsed configuration or null if not found or invalid
82 */
83export async function fetchMoiConfig(baseUrl: string): Promise<MoiConfig | null> {
84 try {
85 // Try to fetch the moi.md file from the project root
86 const response = await fetch(`${baseUrl}/moi.md`);
87
88 // If file doesn't exist, return null
94 return parseFrontmatter(content);
95 } catch (error) {
96 console.error("Error fetching moi.md:", error);
97 return null;
98 }

valtownInstagramindex.ts2 matches

@dcm31•Updated 1 week ago
55}
56
57// Export the fetch handler for HTTP vals
58export default app.fetch;
59
vtProjectSearch

vtProjectSearchdb.ts1 match

@dcm31•Updated 1 week ago
892 const searchPattern = `%${searchText}%`;
893
894 // 3. Start all data fetching queries in parallel, regardless of result type
895 // This way we don't wait for counts to finish before starting data queries
896 const fileResultsPromise = (async () => {
vtProjectSearch

vtProjectSearchcomponents.tsx2 matches

@dcm31•Updated 1 week ago
1240 <h3>Try searching for:</h3>
1241 <div className="search-examples">
1242 <a href="?q=fetch" className="example-link">fetch</a>
1243 <a href="?q=api" className="example-link">api</a>
1244 <a href="?q=database" className="example-link">database</a>
1395 <h3>Try searching for:</h3>
1396 <div className="search-examples">
1397 <a href="?q=fetch" className="example-link">fetch</a>
1398 <a href="?q=api" className="example-link">api</a>
1399 <a href="?q=database" className="example-link">database</a>
vtProjectSearch

vtProjectSearchclient.tsx7 matches

@dcm31•Updated 1 week ago
6 let lastSearchTerm = '';
7 let debounceTimer;
8 let currentRequest = null; // To track the current fetch request
9 let requestCounter = 0; // To identify requests
10 let currentResults = [];
11 let selectedIndex = -1;
12
13 // Function to fetch typeahead results
14 async function fetchTypeahead(query) {
15 if (query.length < 1) {
16 hideResults();
32
33 try {
34 const response = await fetch(\`/typeahead?q=\${encodeURIComponent(query)}\`, { signal });
35 if (!response.ok) throw new Error('Network response was not ok');
36
51 // Ignore abort errors which happen when we cancel the request
52 if (error.name !== 'AbortError') {
53 console.error('Typeahead fetch error:', error);
54 }
55 } finally {
120 // If it's a new query (just one character), search immediately
121 if (query.length === 1) {
122 fetchTypeahead(query);
123 } else {
124 // Otherwise use debounce for better performance during typing
125 debounceTimer = setTimeout(() => {
126 fetchTypeahead(query);
127 }, 200); // Debounce delay
128 }

weatherDashboardmain.tsx4 matches

@rishabhdamelay•Updated 1 week ago
8
9 useEffect(() => {
10 async function fetchWeather() {
11 try {
12 const response = await fetch(
13 `https://api.open-meteo.com/v1/forecast?latitude=${location.latitude}&longitude=${location.longitude}&current_weather=true&hourly=temperature_2m,relativehumidity_2m,windspeed_10m`
14 );
16 setWeather(data);
17 } catch (error) {
18 console.error("Failed to fetch weather", error);
19 }
20 }
21
22 fetchWeather();
23 }, [location]);
24
vtProjectSearch

vtProjectSearchdocsearch.ts4 matches

@dcm31•Updated 1 week ago
83 * @param page Page number
84 * @param pageSize Number of results per page
85 * @param fetchData Whether to fetch the full data for each result
86 */
87export async function searchDocs(
89 page: number = 1,
90 pageSize: number = 10,
91 fetchData: boolean = true
92): Promise<{
93 results: DocSearchResult[];
105
106 // If we don't need the full data, just return the count
107 if (!fetchData) {
108 return { results: [], totalResults: unfilteredResultCount };
109 }
112 const paginatedResults = results.slice(startIndex, endIndex);
113
114 // Fetch all result data in parallel
115 const dataPromises = paginatedResults.map(result => result.data());
116 const resultDataArray = await Promise.all(dataPromises);
vtProjectSearch

vtProjectSearchdeno.lock11 matches

@dcm31•Updated 1 week ago
35 "integrity": "sha512-OF8fFQSkbL7vJY9rfuegK1R7sPgQ6kFMkDamiEccNUvieQ+3urzfDFI616oPl8V7T9zRmnTkSjMOImYCAVRVuw==",
36 "dependencies": [
37 "@libsql/isomorphic-fetch",
38 "@libsql/isomorphic-ws",
39 "js-base64",
40 "node-fetch@3.3.2"
41 ]
42 },
43 "@libsql/isomorphic-fetch@0.3.1": {
44 "integrity": "sha512-6kK3SUK5Uu56zPq/Las620n5aS9xJq+jMBcNSOmjhNf/MUvdyji4vrMTqD7ptY7/4/CAVEAYDeotUz60LNQHtw=="
45 },
69 "integrity": "sha512-kTPhdZyTQxB+2wpiRcFWrDcejc4JI6tkPuS7UZCG4l6Zvc5kU/gGQ/ozvHTh1XR5tS+UlfAfGuPajjzQjCiHCw=="
70 },
71 "@types/node-fetch@2.6.12": {
72 "integrity": "sha512-8nneRWKCg3rMtF69nLQJnOYUcbafYeFSjqkw3jCRLsqkWFlHaoQrr5mXmofFGOx3DKn7UfmBMyov8ySvLRVldA==",
73 "dependencies": [
104 "dependencies": [
105 "@types/node@18.19.86",
106 "@types/node-fetch",
107 "abort-controller",
108 "agentkeepalive",
109 "form-data-encoder",
110 "formdata-node",
111 "node-fetch@2.7.0"
112 ]
113 },
184 "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
185 },
186 "fetch-blob@3.2.0": {
187 "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
188 "dependencies": [
213 "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
214 "dependencies": [
215 "fetch-blob"
216 ]
217 },
300 "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="
301 },
302 "node-fetch@2.7.0": {
303 "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
304 "dependencies": [
306 ]
307 },
308 "node-fetch@3.3.2": {
309 "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
310 "dependencies": [
311 "data-uri-to-buffer",
312 "fetch-blob",
313 "formdata-polyfill"
314 ]

fetchPaginatedData2 file matches

@nbbaier•Updated 2 weeks ago

FetchBasic1 file match

@fredmoon•Updated 2 weeks ago