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/$2?q=fetch&page=29&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 14563 results for "fetch"(3747ms)

stevensDemo.cursorrules5 matches

@bkm•Updated 5 days ago
163```
164
1655. **fetchTranspiledJavaScript** - Fetch and transpile TypeScript to JavaScript:
166```ts
167const jsCode = await fetchTranspiledJavaScript("https://esm.town/v/username/project/path/to/file.ts");
168```
169
242
243 // Inject data to avoid extra round-trips
244 const initialData = await fetchInitialData();
245 const dataScript = `<script>
246 window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
300
3015. **API Design:**
302 - `fetch` handler is the entry point for HTTP vals
303 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
304 - Properly handle CORS if needed for external access

stevensDemoApp.tsx17 matches

@bkm•Updated 5 days ago
82 const [cookieAndTeaMode, setCookieAndTeaMode] = useState(false);
83
84 // Fetch images from backend instead of blob storage directly
85 useEffect(() => {
86 // Set default background color in case image doesn't load
89 }
90
91 // Fetch avatar image
92 fetch("/api/images/stevens.jpg")
93 .then((response) => {
94 if (response.ok) return response.blob();
103 });
104
105 // Fetch wood background
106 fetch("/api/images/wood.jpg")
107 .then((response) => {
108 if (response.ok) return response.blob();
129 }, []);
130
131 const fetchMemories = useCallback(async () => {
132 setLoading(true);
133 setError(null);
134 try {
135 const response = await fetch(API_BASE);
136 if (!response.ok) {
137 throw new Error(`HTTP error! status: ${response.status}`);
154 }
155 } catch (e) {
156 console.error("Failed to fetch memories:", e);
157 setError(e.message || "Failed to fetch memories.");
158 } finally {
159 setLoading(false);
162
163 useEffect(() => {
164 fetchMemories();
165 }, [fetchMemories]);
166
167 const handleAddMemory = async (e: React.FormEvent) => {
176
177 try {
178 const response = await fetch(API_BASE, {
179 method: "POST",
180 headers: { "Content-Type": "application/json" },
188 setNewMemoryTags("");
189 setShowAddForm(false);
190 await fetchMemories();
191 } catch (e) {
192 console.error("Failed to add memory:", e);
199
200 try {
201 const response = await fetch(`${API_BASE}/${id}`, {
202 method: "DELETE",
203 });
205 throw new Error(`HTTP error! status: ${response.status}`);
206 }
207 await fetchMemories();
208 } catch (e) {
209 console.error("Failed to delete memory:", e);
231
232 try {
233 const response = await fetch(`${API_BASE}/${editingMemory.id}`, {
234 method: "PUT",
235 headers: { "Content-Type": "application/json" },
240 }
241 setEditingMemory(null);
242 await fetchMemories();
243 } catch (e) {
244 console.error("Failed to update memory:", e);

TracesStreammain.ts1 match

@wolf•Updated 5 days ago
4
5setInterval(
6 () => fetch("https://wolf--266a00ae4c8c11f0a9af76b3cceeab13.web.val.run"),
7 1_000,
8);

Townieindex.ts1 match

@valdottown•Updated 5 days ago
218});
219
220export default app.fetch;

filterFeedslifeInStitches.tsx1 match

@ljus•Updated 5 days ago
4const videoFeed = "https://www.youtube.com/feeds/videos.xml?channel_id=UC3TpyhwXdKXh_TcBC27QQaw";
5export async function parseFeedFromUrl(url: string) {
6 const response = await fetch(url);
7 const xml = await response.text();
8 const feed = await parseFeed(xml);
266
267 // Inject data to avoid extra round-trips
268 const initialData = await fetchInitialData();
269 const dataScript = `<script>
270 window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
362
3635. **API Design:**
364 - `fetch` handler is the entry point for HTTP vals
365 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
366
367

bluesky-jaws-1975main.tsx1 match

@cheersderek•Updated 5 days ago
127 // load script file
128 // You cannot read files from the file system in Val Town. LOL!
129 const resp = await fetch("https://www.val.town/x/cheersderek/bluesky-jaws-1975/code/jaws-1975.txt");
130 const text = await resp.text();
131 console.log(text);

vtEditorFiles-fixvaltown.mdc3 matches

@nbbaier•Updated 5 days ago
221
222 // Inject data to avoid extra round-trips
223 const initialData = await fetchInitialData();
224 const dataScript = `<script>
225 window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
268
2695. **API Design:**
270 - `fetch` handler is the entry point for HTTP vals
271 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
272
2736. **Hono Peculiarities:**

GIthubProfileindex.tsx6 matches

@anand_g•Updated 5 days ago
339 </div>
340 <div className="mt-4 p-3 bg-blue-50 rounded-lg text-sm text-blue-800">
341 <strong>💡 API Information:</strong> This data is fetched from GitHub's REST API v3.
342 The APIs used are: <code>/users/{`{username}`}</code>, <code>/users/{`{username}`}/repos</code>,
343 and <code>/users/{`{username}`}/events/public</code>.
354 const [error, setError] = useState<string>('');
355
356 const fetchProfile = async (searchUsername: string) => {
357 if (!searchUsername.trim()) return;
358
362
363 try {
364 const response = await fetch(`/api/user/${encodeURIComponent(searchUsername.trim())}`);
365 const data = await response.json();
366
367 if (!response.ok) {
368 throw new Error(data.error || 'Failed to fetch profile');
369 }
370
379 const handleSubmit = (e: React.FormEvent) => {
380 e.preventDefault();
381 fetchProfile(username);
382 };
383
384 // Load a default profile on mount
385 useEffect(() => {
386 fetchProfile('octocat');
387 }, []);
388

GIthubProfileindex.ts12 matches

@anand_g•Updated 5 days ago
76
77// Helper function to make GitHub API requests
78async function fetchGitHubAPI(endpoint: string): Promise<any> {
79 const headers: Record<string, string> = {
80 'Accept': 'application/vnd.github.v3+json',
88 }
89
90 const response = await fetch(`https://api.github.com${endpoint}`, {
91 headers
92 });
111}
112
113// API endpoint to fetch GitHub user profile data
114app.get("/api/user/:username", async c => {
115 try {
120 }
121
122 // Fetch user data
123 const userResponse = await fetchGitHubAPI(`/users/${username}`);
124
125 // Fetch user's repositories (latest 10, sorted by updated)
126 const reposResponse = await fetchGitHubAPI(`/users/${username}/repos?sort=updated&per_page=10`);
127
128 // Fetch user's recent public events (latest 10)
129 const eventsResponse = await fetchGitHubAPI(`/users/${username}/events/public?per_page=10`);
130
131 const profileData: GitHubProfileData = {
142 return c.json(profileData);
143 } catch (error) {
144 console.error("Error fetching GitHub data:", error);
145
146 // If it's a rate limit error and the user is 'octocat', return demo data
150
151 return c.json({
152 error: error instanceof Error ? error.message : "Failed to fetch GitHub data"
153 }, 500);
154 }
252});
253
254export default app.fetch;

testWeatherFetcher1 file match

@sjaskeprut•Updated 4 days ago

weatherFetcher1 file match

@sjaskeprut•Updated 4 days ago