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=786&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 8150 results for "fetch"(2446ms)

lichessTVGamesmain.tsx2 matches

@jdan•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3type GameType =
30type Games = Record<GameType, Entry>;
31export async function lichessTVGames(): Promise<Games> {
32 const channels = await fetch("https://lichess.org/api/tv/channels");
33 return await channels.json();
34}

validatePostExistsmain.tsx3 matches

@merlin•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const validatePostExists = async (slug) => {
4 const response = await fetch("https://www.merlinmason.co.uk/posts.json");
5 if (!response.ok) {
6 throw new Error("Failed to fetch posts");
7 }
8 const posts = await response.json();

YoutubeTranscriptmain.tsx11 matches

@zzz•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const YoutubeTranscript = async (url: string, metadata = true) => {
76 }
77 /**
78 * An extensible class to fetch a transcript from a given YouTube Video
79 */
80 class YoutubeTranscript {
81 /**
82 * Fetch a transcript from a YouTube Video which includes the text and timestamp metadata
83 * @param videoId Video url or video identifier
84 * @param config Options for specifying a Country and Language ISO
85 */
86 static async fetchTranscript(
87 videoId: string,
88 config?: TranscriptConfig,
90 const identifier = this.extractVideoId(videoId);
91 try {
92 const textResponse = await fetch(
93 `https://www.youtube.com/watch?v=${identifier}`,
94 );
100 );
101 }
102 const transcriptResponse = await fetch(
103 `https://www.youtube.com/youtubei/v1/get_transcript?key=${apiKey}`,
104 {
123 }
124 /**
125 * Fetch only the transcript text from a YouTube Video
126 * @param videoId Video url or video identifier
127 * @param config Options for specifying a Country and Language ISO
128 */
129 static async fetchTranscriptText(
130 videoId: string,
131 config?: TranscriptConfig,
132 ): Promise<string> {
133 const segments = await this.fetchTranscript(videoId, config);
134 let out = "";
135 for (const { text } of segments) {
283 }
284 if (metadata)
285 return await YoutubeTranscript.fetchTranscript(url);
286 return await YoutubeTranscript.fetchTranscriptText(url);
287};

hnTopStoriesmain.tsx5 matches

@csshsh•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3// forked from @healeycodes.hnTopStories
5// hi florian
6export const hnTopStories = async () => {
7 let valTownFetchLimit = 1;
8 const topStories: Number[] = await fetch(
9 "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty"
10 ).then((res) => res.json());
11 valTownFetchLimit--;
12 const id = topStories[0];
13 console.log({ id });
19 score: number;
20 by: string;
21 } = await fetch(
22 `https://hacker-news.firebaseio.com/v0/item/${id}.json?print=pretty`
23 ).then((res) => res.json());

ratelimitmain.tsx2 matches

@rlimit•Updated 1 year ago
1import { parentReference } from "https://esm.town/v/stevekrouse/parentReference?v=3";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
3import { runVal } from "https://esm.town/v/std/runVal";
4
12 // use user's rlimit.com namespace if defined
13 if (namespaceId) {
14 return await fetchJSON(
15 `https://rlimit.com/${namespaceId}/${max}/${interval}/${key}?password=${namespacePassword}&region=global`,
16 );

replitGetmain.tsx2 matches

@claytn•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let replitGet = (REPLIT_DB_URL, key) => fetch(`${REPLIT_DB_URL}/${key}`);

pollVotingJobmain.tsx2 matches

@pranjaldotdev•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3let { failureCount } = await import("https://esm.town/v/pranjaldotdev/failureCount");
20 const token =
21 "eyJhbGciOiJIUzI1NiJ9.eyJwbGF0Zm9ybSI6Imppb3Zvb3QiLCJ1c2VyaWR0eXBlIjoidXVpZCIsImlzSmlvVXNlciI6ZmFsc2UsImlzR3Vlc3QiOmZhbHNlLCJwaG9uZU5vIjoiMzM2NjBiNzQtM2U5YS00ZWJhLTlmMTMtNzBkNTQ3NmUwOTNkIiwicHJvZmlsZUlkIjoiMTE1ODc3YWQtZDE3Mi00YTAwLWI2OTMtMDlkZmNjNTEwOTMyIiwiaWF0IjoxNjg5NzA0MzA0LCJleHAiOjE2ODk3OTA3MDR9.ICKpSLJJexKR0wjDYDMpctvdTV33P0J6pxL3MAxWJyg";
22 const response = await fetch(votingURL, {
23 method: "POST",
24 headers: {

getWeathermain.tsx4 matches

@sdan•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function getWeather(city: string) {
4 try {
5 const response = await fetch(`https://wttr.in/${city}?format=j1`);
6 if (!response.ok) {
7 throw new Error(`Failed to fetch data for ${city}`);
8 }
9 const jsonData = await response.json();
14 }
15 catch (error) {
16 throw new Error(`Failed to fetch weather data: ${error}`);
17 }
18}

big_storymain.tsx2 matches

@tmcw•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { big_stories_ranks } from "https://esm.town/v/tmcw/big_stories_ranks";
3import process from "node:process";
5export let big_story = (async () => {
6 const nytimes =
7 await (await fetch(
8 `https://api.nytimes.com/svc/topstories/v2/home.json?api-key=${process.env.nytimes_api_key}`,
9 )).json();

testVTClientmain.tsx1 match

@stevekrouse•Updated 1 year ago
5 const apiClient = createApiClient("https://api.val.town");
6 const params = {
7 params: { username: "stevekrouse", val_name: "fetchJSON" },
8 };
9 const user = await apiClient.getValname(params);

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago