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=3&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 13944 results for "fetch"(2649ms)

Snotel-Analyzerindex.ts6 matches

@bjtitusUpdated 11 hours ago
30 ];
31
32 const response = await fetch(
33 `https://wcc.sc.egov.usda.gov/awdbRestApi/services/v1/stations?stationIds=${coStationIds.join(',')}`
34 );
59 return c.json(apiResponse);
60 } catch (error) {
61 console.error("Error fetching sites:", error);
62 const apiResponse: ApiResponse<SnotelSite[]> = {
63 success: false,
85 ];
86
87 // Fetch recent data for these stations
88 const dataResponse = await fetch(
89 `https://wcc.sc.egov.usda.gov/awdbRestApi/services/v1/data?stationIds=${coStationIds.join(',')}&elementCds=SNWD,WTEQ,TOBS&ordinal=1&duration=DAILY&getFlags=false&alwaysReturnDailyFeb29=false&format=json&beginDate=${formatDate(startDate)}&endDate=${formatDate(endDate)}`
90 );
143 return c.json(apiResponse);
144 } catch (error) {
145 console.error("Error fetching data:", error);
146 const apiResponse: ApiResponse<SnotelData[]> = {
147 success: false,
152});
153
154export default app.fetch;

Snotel-Analyzerindex.html10 matches

@bjtitusUpdated 11 hours ago
34
35 useEffect(() => {
36 fetchData();
37 }, []);
38
39 const fetchData = async () => {
40 try {
41 setLoading(true);
42 setError(null);
43
44 // Fetch sites and data in parallel
45 const [sitesResponse, dataResponse] = await Promise.all([
46 fetch('/api/sites'),
47 fetch('/api/data')
48 ]);
49
52
53 if (!sitesResult.success) {
54 throw new Error(sitesResult.error || 'Failed to fetch sites');
55 }
56
57 if (!dataResult.success) {
58 throw new Error(dataResult.error || 'Failed to fetch data');
59 }
60
63 } catch (err) {
64 setError(err.message);
65 console.error('Error fetching data:', err);
66 } finally {
67 setLoading(false);
103 </div>
104 <button
105 onClick={fetchData}
106 className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
107 >
122 </p>
123 <button
124 onClick={fetchData}
125 className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded transition-colors"
126 >

Snotel-AnalyzerREADME.md3 matches

@bjtitusUpdated 11 hours ago
7- Displays latest snow and weather data from SNOTEL sites
8- Interactive table with site information
9- Real-time data fetching from USDA AWDB API
10
11## Project Structure
19
20- `GET /` - Serves the main application
21- `GET /api/sites` - Fetches SNOTEL site data
22- `GET /api/data/:stationId` - Fetches latest data for a specific station
23
24## Usage

tex-primitivesmain.ts2 matches

@aeatonUpdated 12 hours ago
1export default async function(req: Request): Promise<Response> {
2 // fetch tex.web and extract all the lines containing primitive descriptions
3 // e.g. primitive("lineskip",assign_glue,glue_base+line_skip_code);@/
4 const url = "https://mirror.ox.ac.uk/sites/ctan.org/systems/knuth/dist/tex/tex.web";
5 const response = await fetch(url);
6 const text = await response.text();
7 const content = text.replaceAll(/\s+/g, "");

live-reloaddemo.tsx2 matches

@stevekrouseUpdated 13 hours ago
21
22app.onError((e) => Promise.reject(e));
23export default app.fetch
24// export default liveReload(app.fetch, import.meta.url);

GlancergeneratePDF.ts1 match

@lightweightUpdated 13 hours ago
1// Convert image URL to base64
2async function getImageBase64(url: string): Promise<string> {
3 const res = await fetch(url);
4 const buffer = await res.arrayBuffer();
5 const base64 = btoa(String.fromCharCode(...new Uint8Array(buffer)));

osindex.ts4 matches

@dinavinterUpdated 13 hours ago
36 });
37
38 const response = await fetch(url, {
39 method: "POST",
40 headers: { "Content-Type": "application/x-www-form-urlencoded" },
65 return response;
66 } catch (error) {
67 console.error(`Error fetching account info for UID ${uid}:`, error);
68 return null;
69 }
141 return response;
142 } catch (error) {
143 console.error("Error fetching account schema:", error);
144 return null;
145 }
483});
484
485export default app.fetch;

Loudaily_lineup_scheduler.tsx9 matches

@jeffvincentUpdated 13 hours ago
183 // Call MLB Stats API for probable pitchers
184 const dateStr = date.toISOString().split("T")[0];
185 const response = await fetch(
186 `https://statsapi.mlb.com/api/v1/schedule?sportId=1&date=${dateStr}&hydrate=probablePitcher`,
187 );
216 return pitchers;
217 } catch (error) {
218 console.error(`❌ Error fetching probable pitchers:`, error);
219 return [];
220 }
351 private async refreshAccessToken(): Promise<void> {
352 try {
353 const response = await fetch("https://api.login.yahoo.com/oauth2/get_token", {
354 method: "POST",
355 headers: {
398 await this.ensureValidToken();
399
400 const response = await fetch(`${this.baseUrl}${endpoint}?format=json`, {
401 headers: {
402 "Authorization": `Bearer ${this.config.access_token}`,
411
412 // Retry the request with new token
413 const retryResponse = await fetch(`${this.baseUrl}${endpoint}?format=json`, {
414 headers: {
415 "Authorization": `Bearer ${this.config.access_token}`,
457 return leagues;
458 } catch (error) {
459 console.error("Error fetching user leagues:", error);
460 return [];
461 }
507 return players;
508 } catch (error) {
509 console.error(`Error fetching roster for team ${teamKey}:`, error);
510 return [];
511 }
514 async setPlayerPosition(teamKey: string, playerId: string, position: string): Promise<void> {
515 // Yahoo Fantasy API requires PUT/POST for roster changes
516 const response = await fetch(`${this.baseUrl}/teams;team_keys=${teamKey}/roster/players;player_keys=${playerId}`, {
517 method: "PUT",
518 headers: {
558
559 // Store results in Val.town's blob storage for history
560 await fetch("https://api.val.town/v1/blob/scheduler_results", {
561 method: "POST",
562 headers: {

osAccountForm.tsx1 match

@dinavinterUpdated 14 hours ago
99
100 try {
101 const response = await fetch('${submitUrl}', {
102 method: '${method}',
103 headers: {

orbiterHealthmonitor3 matches

@stevedylandevUpdated 14 hours ago
10async function notifySlack(message: string) {
11 try {
12 await fetch(WEBHOOK_URL, {
13 method: "POST",
14 headers: {
29 const start = performance.now();
30 try {
31 const res = await fetch(url);
32 end = performance.now();
33 status = res.status;
40 } catch (e) {
41 end = performance.now();
42 reason = `couldn't fetch: ${e}`;
43 ok = false;
44 console.log(`Website down (${url}): ${reason} (${end - start}ms)`);

FetchBasic2 file matches

@therUpdated 4 days ago

GithubPRFetcher

@andybakUpdated 1 week ago