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=760&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 7895 results for "fetch"(1661ms)

getRandomDogImgmain.tsx3 matches

@mutuguangda•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const getRandomDogImg = async (
5 res: express.Response,
6) => {
7 const data = await fetch("https://dog.ceo/api/breeds/image/random", {
8 method: "get",
9 redirect: "follow",
19 catch (e) {
20 throw new Error(
21 `fetchJSON error: ${e.message} in ${req.baseUrl}\n\n"${t}"`,
22 );
23 }

searchManifoldMarketsmain.tsx2 matches

@piotr•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3type Market = {
6};
7export async function searchManifoldMarkets(query: string) {
8 const result = await fetch(
9 `https://manifold.markets/api/v0/search-markets?${query}`,
10 );

tidbytDeviceInfomain.tsx2 matches

@andreterron•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3export function tidbytDeviceInfo({ deviceId, apiKey }: {
5 apiKey: string;
6}) {
7 return fetchJSON(
8 `https://api.tidbyt.com/v0/devices/${deviceId}`,
9 {

nameNationalitymain.tsx2 matches

@raphaelrk•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3// Predict the nationality of a name
4export let nameNationality = fetchJSON(
5 "https://api.nationalize.io/?name=michael"
6);

fetchJSONmain.tsx3 matches

@pixelian•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let fetchJSON = async (url: string, options?: any) => {
4 let f = await fetch(url, {
5 ...options,
6 headers: {

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 );

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago