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/$%7Burl%7D?q=fetch&page=1077&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 13280 results for "fetch"(5646ms)

codeOnValTownmain.tsx3 matches

@Serizon•Updated 9 months ago
37
38/**
39 * @param handler Fetch handler
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style }: { val?: ValRef; style?: string } = {},
52}
53
54export default modifyFetchHandler;

umapmain.tsx3 matches

@ejfox•Updated 9 months ago
142 <h3>Basic Example:</h3>
143 <pre>
144fetch("https://ejfox-umap.web.val.run/", {
145 method: "POST",
146 headers: { "Content-Type": "application/json" },
183const embeddings = await getEmbeddings(texts);
184
185fetch("/", {
186 method: "POST",
187 headers: { "Content-Type": "application/json" },
209 };
210
211 fetch("https://ejfox-umap.web.val.run", {
212 method: "POST",
213 headers: { "Content-Type": "application/json" },

zod_demo_frontendmain.tsx1 match

@stevekrouse•Updated 9 months ago
19
20 // Send data to server
21 const response = await fetch("/register", {
22 method: "POST",
23 headers: { "Content-Type": "application/json" },

blob_adminmain.tsx2 matches

@lithrel•Updated 9 months ago
1/** @jsxImportSource https://esm.sh/hono@4.0.8/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import view_route from "https://esm.town/v/pomdtr/blob_admin_blob";
5import create_route from "https://esm.town/v/pomdtr/blob_admin_create";
137});
138
139export default modifyFetchHandler(passwordAuth(app.fetch));

weatherGPTmain.tsx1 match

@sarfrazkhan18•Updated 9 months ago
4let location = "brooklyn ny";
5let lang = "en";
6const weather = await fetch(
7 `https://wttr.in/${location}?lang=${lang}&format=j1`,
8).then(r => r.json());

umbrellaRemindermain.tsx2 matches

@sarfrazkhan18•Updated 9 months ago
1import { email } from "https://esm.town/v/std/email?v=9";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3import { nominatimSearch } from "https://esm.town/v/stevekrouse/nominatimSearch";
4import { weatherGovGrid } from "https://esm.town/v/stevekrouse/weatherGovGrid";
14 lon,
15 });
16 let { properties: { periods } } = await fetchJSON(
17 grid.forecastHourly,
18 );

turnitdownmain.tsx1 match

@yawnxyz•Updated 9 months ago
83
84export default async function server(req: Request): Promise<Response> {
85 return app.fetch(req);
86}

iconExplorermain.tsx5 matches

@all•Updated 9 months ago
2 * This val creates an enhanced NPM package explorer using the npm registry API.
3 * It displays a grid of npm packages with basic information, categories, and navigation.
4 * The approach uses React for the frontend and fetch for API calls.
5 * It includes a details view for each package, a link to the npm page, and category navigation.
6 */
20
21 useEffect(() => {
22 fetchPackages();
23 }, [searchTerm, category, page]);
24
25 const fetchPackages = () => {
26 let url = `/search?q=${encodeURIComponent(searchTerm)}&size=${ITEMS_PER_PAGE}&from=${(page - 1) * ITEMS_PER_PAGE}`;
27 if (category !== "all") {
28 url += `&category=${encodeURIComponent(category)}`;
29 }
30 fetch(url)
31 .then(response => response.json())
32 .then(data => setPackages(data.objects));
114 }
115
116 const response = await fetch(apiUrl);
117 const data = await response.json();
118 return new Response(JSON.stringify(data), {

todaystatsmain.tsx45 matches

@ejfox•Updated 9 months ago
1/**
2 * This tool fetches real-time data from various free APIs to create a JSON object
3 * representing the current state of the world from different perspectives.
4 * Data is cached for 30 minutes using Val Town's SQLite database to reduce API calls and improve performance.
21}
22
23// Utility function for fetching JSON data
24async function fetchJSON(url: string) {
25 try {
26 const response = await fetch(url);
27 if (!response.ok) {
28 throw new Error(`HTTP error! status: ${response.status}`);
30 return await response.json();
31 } catch (error) {
32 console.error(`Error fetching ${url}:`, error);
33 return null;
34 }
40}
41
42// Utility function for fetching Wolfram Alpha data
43async function fetchWolframData(query: string) {
44 const appId = 'K8UTGR-8Y5G3A3VTP';
45 const url = `http://api.wolframalpha.com/v1/result?appid=${appId}&i=${encodeURIComponent(query)}`;
46 try {
47 const response = await fetch(url);
48 if (!response.ok) {
49 throw new Error(`HTTP error! status: ${response.status}`);
51 return await response.text();
52 } catch (error) {
53 console.error(`Error fetching Wolfram data for query "${query}":`, error);
54 return null;
55 }
56}
57
58// Utility function for fetching Alpha Vantage stock data
59async function fetchStockData(symbol: string) {
60 const apiKey = 'TD7I78XY3N2AGKWP';
61 const url = `https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=${symbol}&interval=5min&apikey=${apiKey}`;
62 try {
63 const data = await fetchJSON(url);
64 if (data && data['Time Series (5min)']) {
65 const latestTimestamp = Object.keys(data['Time Series (5min)'])[0];
70 }
71 } catch (error) {
72 console.error(`Error fetching stock data for symbol ${symbol}:`, error);
73 return null;
74 }
90 }
91
92 // If no valid cache, fetch new data
93 const issData = await fetchJSON('http://api.open-notify.org/iss-now.json');
94 const weatherData = await fetchJSON('https://api.open-meteo.com/v1/forecast?latitude=40.71&longitude=-74.01&current_weather=true&temperature_unit=celsius&daily=temperature_2m_max,temperature_2m_min,sunrise,sunset&timezone=America%2FNew_York');
95 const airQualityData = await fetchJSON('https://api.waqi.info/feed/geo:40.71;-74.01/?token=demo');
96 const cryptoData = await fetchJSON('https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum,dogecoin,ripple,cardano,polkadot,litecoin&vs_currencies=usd');
97 const peopleInSpaceData = await fetchJSON('http://api.open-notify.org/astros.json');
98 const timeData = await fetchJSON('https://worldtimeapi.org/api/timezone/America/New_York,Europe/London,Asia/Tokyo');
99 const exchangeRateData = await fetchJSON('https://api.exchangerate-api.com/v4/latest/USD');
100 const usaCovidData = await fetchJSON('https://disease.sh/v3/covid-19/countries/USA');
101 const solarData = await fetchJSON('https://services.swpc.noaa.gov/json/solar-cycle/observed-solar-cycle-indices.json');
102 const earthquakeData = await fetchJSON('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson');
103
104 const worldPopulation = await fetchWolframData('current world population');
105 const carbonDioxide = await fetchWolframData('current atmospheric CO2');
106 const internetUsers = await fetchWolframData('number of internet users');
107 const globalTemperature = await fetchWolframData('current global average temperature');
108 const moonPhase = await fetchWolframData('current moon phase');
109 const usUnemploymentRate = await fetchWolframData('current US unemployment rate');
110 const globalInflationRate = await fetchWolframData('current global inflation rate');
111 const oilPrice = await fetchWolframData('current oil price');
112 const goldPrice = await fetchWolframData('current gold price');
113
114 const sp500 = await fetchStockData('SPY');
115 const dowJones = await fetchStockData('DIA');
116 const nasdaq = await fetchStockData('QQQ');
117 const appleStock = await fetchStockData('AAPL');
118 const nvidiaStock = await fetchStockData('NVDA');
119 const teslaStock = await fetchStockData('TSLA');
120 const amazonStock = await fetchStockData('AMZN');
121 const googleStock = await fetchStockData('GOOGL');
122
123 const worldState = {
267 </div>
268 <script>
269 async function fetchData() {
270 try {
271 const response = await fetch(window.location.href);
272 const data = await response.json();
273 document.getElementById('data').textContent = JSON.stringify(data, null, 2);
274 } catch (error) {
275 console.error('Error:', error);
276 document.getElementById('data').textContent = 'Error fetching data';
277 }
278 }
279 fetchData();
280 </script>
281</body>

daisyui_honomain.tsx1 match

@lnncoco•Updated 9 months ago
39});
40
41export default app.fetch;

GithubPRFetcher

@andybak•Updated 14 hours ago

proxiedfetch1 file match

@jayden•Updated 1 day ago