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/$%7Bart_info.art.src%7D?q=fetch&page=781&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 8075 results for "fetch"(2290ms)

extractWikipediaMainTextmain.tsx7 matches

@fab1an•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const extractWikipediaMainText = async () => {
7 const extractWikipediaContent = async (url) => {
8 try {
9 const response = await fetch(url);
10 const html = await response.text();
11 const parser = new DOMParser();
20 return `${textContent.trim()}`;
21 } catch (error) {
22 console.log("Error fetching Wikipedia content:", error);
23 return `An error occurred while fetching the Wikipedia content. ${error}`;
24 }
25 };
27 const randomWikiURL = "https://en.wikipedia.org/wiki/Special:Random";
28 try {
29 const response = await fetch(randomWikiURL, { redirect: "manual" });
30 const location = response.headers.get("location");
31 return location;
32 } catch (error) {
33 console.log("Error fetching random Wikipedia URL:", error);
34 return `An error occurred while fetching the random Wikipedia URL. ${error}`;
35 }
36 };

getRandomArticleInCategorymain.tsx5 matches

@fab1an•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const getRandomArticleInCategory = async (category) => {
13 const listUrl =
14 `https://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:${encodedCategory}&cmlimit=500&format=json&origin=*`;
15 const listResponse = await fetch(listUrl);
16 const listData = await listResponse.json();
17 if (!listData.query.categorymembers.length) {
28 encodeURIComponent(randomArticle)
29 }&format=json&utf8=1&origin=*`;
30 const contentResponse = await fetch(contentUrl);
31 const contentData = await contentResponse.json();
32 const pageId = Object.keys(contentData.query.pages)[0];
38 }
39 catch (error) {
40 console.log("Error fetching Wikipedia content:", error);
41 return `An error occurred while fetching the Wikipedia content. ${error}`;
42 }
43};

mathFactmain.tsx2 matches

@dosirak•Updated 1 year ago
1import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=5";
2
3// Random math fact
4export let mathFact = fetchText(
5 "http://numbersapi.com/random/math"
6);

goodReadsmain.tsx2 matches

@dfl•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let goodReads = (url) => {
4 const resp = await fetch(url);
5
6 console.log("url: ", url, resp);

githubGistsmain.tsx2 matches

@eagle251•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3// GitHub gists
4export let githubGists = fetchJSON(
5 "https://api.github.com/users/stevekrouse/gists"
6);

TanaPasteExamplemain.tsx1 match

@bikefixe•Updated 1 year ago
5 // a search term might've been passed in
6 // const url = https://something@domain.com?searchterm=${req.query.arg}
7 // let response = await fetch(url);
8 // const theText = JSON.parse(await response.text());
9 // continue assuming theText had been filled with response text

discordGetMembersmain.tsx2 matches

@vtdocs•Updated 1 year ago
1import { discordFetch } from "https://esm.town/v/vtdocs/discordFetch";
2
3export const discordGetMembers = async (
9 let highestId = BigInt(0);
10 while (true) {
11 const result = await discordFetch(
12 botToken,
13 `/guilds/${serverId}/members?limit=1000&after=${highestId}`,

untitled_xqPioNn3main.tsx2 matches

@root•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const untitled_xqPioNn3 = await fetch("https://www.baidu.com");

getMemain.tsx2 matches

@neverstew•Updated 1 year ago
1import process from "node:process";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
3
4export let getMe = fetchJSON(`https://api.val.town/v1/me`, {
5 headers: {
6 Authorization: `Bearer ${process.env.valtownToken}`,

stockPriceVizmain.tsx2 matches

@joemccourt•Updated 1 year ago
1import process from "node:process";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
3
4export async function stockPriceViz(req: Request) {
7 const symbol = params.get("symbol");
8 const d = params.get("d");
9 const resData = await fetchJSON(
10 `https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=${symbol}&interval=${d}min&apikey=${process.env.alphaVantage}`,
11 );

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago