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=565&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 8288 results for "fetch"(1737ms)

sqliteExplorerAppmain.tsx4 matches

@wxw•Updated 8 months ago
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { iframeHandler } from "https://esm.town/v/nbbaier/iframeHandler";
5import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
16import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
17import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
18import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
19import { Hono } from "npm:hono";
20import type { FC } from "npm:hono/jsx";
175});
176
177export const handler = app.fetch;
178export default iframeHandler(modifyFetchHandler(passwordAuth(handler, { verifyPassword: verifyToken })));

closedChocolateMarmosetmain.tsx1 match

@jdan•Updated 8 months ago
25 visited.add(url);
26
27 const response = await fetch(url);
28 const html = await response.text();
29 const $ = cheerio.load(html);

sqliteExplorerAppmain.tsx4 matches

@jpaulgale•Updated 8 months ago
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { iframeHandler } from "https://esm.town/v/nbbaier/iframeHandler";
5import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
16import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
17import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
18import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
19import { Hono } from "npm:hono";
20import type { FC } from "npm:hono/jsx";
175});
176
177export const handler = app.fetch;
178export default iframeHandler(modifyFetchHandler(passwordAuth(handler, { verifyPassword: verifyToken })));

lucia_demomain.tsx1 match

@yawnxyz•Updated 8 months ago
233});
234
235export default app.fetch;

hackerNewsDigestmain.tsx8 matches

@mihai•Updated 8 months ago
3import { email } from "https://esm.town/v/std/email";
4
5async function fetchStories(type: string, count: number) {
6 const response = await fetch(`https://hacker-news.firebaseio.com/v0/${type}stories.json`);
7 const storyIds = await response.json();
8 const stories = await Promise.all(
9 storyIds.slice(0, count).map(async (id: number) => {
10 const storyResponse = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`);
11 return storyResponse.json();
12 }),
120export default async function server(req: Request) {
121 try {
122 const topStories = await fetchStories("top", 20);
123 const newStories = await fetchStories("new", 5);
124 const showStories = await fetchStories("show", 3);
125 const askStories = await fetchStories("ask", 3);
126 const jobStories = await fetchStories("job", 3);
127
128 const emailContent = createEmailContent(topStories, newStories, showStories, askStories, jobStories);

theHereTimesmain.tsx18 matches

@gio•Updated 8 months ago
2 * This application creates "The Here Times", a map-based news aggregator.
3 * It uses the Google Maps JavaScript API for map rendering, Geonames for location data,
4 * and the NewsAPI for fetching news articles.
5 * The app displays news for the top 12 most populous cities/neighborhoods in the current map view.
6 *
8 * 1. Use Google Maps JavaScript API for rendering the map
9 * 2. Use Geonames API to get top 12 most populous cities within the map bounds
10 * 3. Fetch news data from NewsAPI based on these locations
11 * 4. Display news articles in a side drawer, only showing articles that contain the city's name in the title
12 * 5. Place markers on the map for each location (exactly 12)
37 const initMap = async () => {
38 try {
39 const response = await fetch("/api/maps-key");
40 const { apiKey } = await response.json();
41
95 const sw = bounds.getSouthWest();
96
97 await fetchLocationsAndNews(sw.lat(), sw.lng(), ne.lat(), ne.lng());
98 });
99 } catch (error) {
113 }, [map, locations, googleMaps]);
114
115 const fetchLocationsAndNews = async (south, west, north, east) => {
116 try {
117 const locationResponse = await fetch(`/api/locations?south=${south}&west=${west}&north=${north}&east=${east}`);
118 if (!locationResponse.ok) {
119 throw new Error(`HTTP error! status: ${locationResponse.status}`);
120 }
121 const fetchedLocations = await locationResponse.json();
122 console.log("Fetched locations:", fetchedLocations.length);
123 const limitedLocations = fetchedLocations.slice(0, 12);
124 setLocations(limitedLocations);
125 console.log("Set locations:", limitedLocations.length);
126
127 const newsPromises = limitedLocations.map(location =>
128 fetch(`/api/news?location=${encodeURIComponent(location.name)}`)
129 .then(async response => {
130 if (!response.ok) {
147 setError(null);
148 } catch (error) {
149 console.error("Error fetching locations and news:", error);
150 setError(`Failed to fetch news: ${error.message}. Please try again later.`);
151 setNews([]);
152 setLocations([]);
295
296 try {
297 const response = await fetch(geonamesUrl);
298 if (!response.ok) {
299 throw new Error(`Geonames API responded with status: ${response.status}`);
301 const data = await response.json();
302 if (data.geonames && Array.isArray(data.geonames)) {
303 console.log("Server: Fetched locations:", data.geonames.length);
304 return new Response(JSON.stringify(data.geonames.slice(0, 12)), {
305 headers: { "Content-Type": "application/json" },
309 }
310 } catch (error) {
311 console.error("Error fetching location data:", error);
312 return new Response(JSON.stringify({ error: error.message }), {
313 status: 500,
335 }
336
337 console.log(`Fetching news for ${location} from ${apiUrl}`);
338
339 const response = await fetch(apiUrl);
340
341 if (!response.ok) {
372 }));
373
374 console.log(`Server: Fetched news for ${location}:`, newsData.length);
375 return new Response(JSON.stringify(newsData), {
376 headers: { "Content-Type": "application/json" },

infoboxCrawlermain.tsx1 match

@stevekrouse•Updated 8 months ago
26 visited.add(url);
27
28 const response = await fetch(url);
29 const html = await response.text();
30 const $ = cheerio.load(html);

hackerNewsDigestmain.tsx8 matches

@gitgrooves•Updated 8 months ago
3import { email } from "https://esm.town/v/std/email";
4
5async function fetchStories(type: string, count: number) {
6 const response = await fetch(`https://hacker-news.firebaseio.com/v0/${type}stories.json`);
7 const storyIds = await response.json();
8 const stories = await Promise.all(
9 storyIds.slice(0, count).map(async (id: number) => {
10 const storyResponse = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`);
11 return storyResponse.json();
12 }),
120export default async function server(req: Request) {
121 try {
122 const topStories = await fetchStories("top", 10);
123 const newStories = await fetchStories("new", 5);
124 const showStories = await fetchStories("show", 3);
125 const askStories = await fetchStories("ask", 3);
126 const jobStories = await fetchStories("job", 3);
127
128 const emailContent = createEmailContent(topStories, newStories, showStories, askStories, jobStories);

sqliteExplorerAppmain.tsx4 matches

@adamwolf•Updated 8 months ago
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { iframeHandler } from "https://esm.town/v/nbbaier/iframeHandler";
5import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
16import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
17import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
18import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
19import { Hono } from "npm:hono";
20import type { FC } from "npm:hono/jsx";
175});
176
177export const handler = app.fetch;
178export default iframeHandler(modifyFetchHandler(passwordAuth(handler, { verifyPassword: verifyToken })));

infoboxCrawlermain.tsx1 match

@jdan•Updated 8 months ago
24 visited.add(url);
25
26 const response = await fetch(url);
27 const html = await response.text();
28 const $ = cheerio.load(html);

fetchPaginatedData2 file matches

@nbbaier•Updated 2 weeks ago

FetchBasic1 file match

@fredmoon•Updated 2 weeks ago