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=727&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 8301 results for "fetch"(2531ms)

fetchTextWithCachingmain.tsx6 matches

@iakovos•Updated 1 year ago
1import { feedCache } from "https://esm.town/v/iakovos/feedCache";
2import { fetch } from "https://esm.town/v/std/fetch";
3import { set } from "https://esm.town/v/std/set?v=11";
4
5export const fetchTextWithCaching = async (url: string): Promise<string | null> => {
6 const cacheItem = feedCache[url];
7 const headers: Record<string, string> = {};
16
17 try {
18 const response = await fetch(url, { headers });
19
20 if (response.status === 304) {
27
28 feedCache[url] = {
29 lastFetched: Date.now(),
30 etag: response.headers.get("ETag") ?? cacheItem?.etag,
31 lastModified: response.headers.get("Last-Modified")
36 ...feedCache,
37 [url]: {
38 lastFetched: Date.now(),
39 etag: response.headers.get("ETag") ?? cacheItem?.etag,
40 lastModified: response.headers.get("Last-Modified")
52 }
53 catch (error) {
54 console.error("Failed to fetch feeds:", error);
55 return null;
56 }

fetchAndParseFeedsmain.tsx4 matches

@iakovos•Updated 1 year ago
1import { extractContent } from "https://esm.town/v/iakovos/extractContent";
2import { fetchText } from "https://esm.town/v/iakovos/fetchText";
3import { getLink } from "https://esm.town/v/iakovos/getLink";
4import { getMediaAttributeUrl } from "https://esm.town/v/iakovos/getMediaAttributeUrl";
5
6export const fetchAndParseFeeds = async (url: string): Promise<FeedItem[]> => {
7 try {
8 const { xml2js } = await import("https://deno.land/x/xml2js@1.0.0/mod.ts");
9 let { parse } = await import("npm:node-html-parser");
10 const xml = await fetchText(url);
11
12 if (!xml) {
41 return parsedItems;
42 } catch (error) {
43 console.error("Error while fetching and parsing feeds:", error);
44 return [];
45 }

animemain.tsx4 matches

@yieldray•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { sify } from "npm:chinese-conv";
3
4const getAll = async () => {
5 const txt = await fetch("https://d1zquzjgwo9yb.cloudfront.net/").then((r) => r.text());
6 const list = (
7 JSON.parse(sify(txt)) as Array<
32const getCat = async (catOrName: number | string) => {
33 const cat = typeof catOrName === "string" ? await nameToCat(catOrName) : catOrName;
34 const res = await fetch("https://anime1.me/?cat=" + cat);
35 if (!res.ok) throw new Error(res.statusText);
36 const html = await res.text();
63 const ep = cat.find((c) => c.episode.startsWith(String(episode)));
64 if (!ep) throw new Error("Episode not exists");
65 const res = await fetch("https://v.anime1.me/api", {
66 method: "POST",
67 headers: {

arxivSourceZipmain.tsx2 matches

@aleaf•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { Buffer } from "node:buffer";
3
9 );
10 const url = id.replace("/abs/", "/e-print/");
11 const response = await fetch(url);
12 if (!response.ok) {
13 throw new Error(await response.text());

htmxExamplemain.tsx1 match

@neverstew•Updated 1 year ago
49 </li>,
50 )));
51 return app.fetch(request);
52};

getAccessTokenmain.tsx1 match

@raymondcamden•Updated 1 year ago
5 params.append("scope", "openid,AdobeID,read_organizations");
6
7 let resp = await fetch(`https://ims-na1.adobelogin.com/ims/token/v2?client_id=${id}`, {
8 method: "POST",
9 body: params,

getRedditAccessTokenmain.tsx2 matches

@tambre•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { Buffer } from "node:buffer";
3import process from "node:process";
13 `${process.env.reddit_client_id}:${process.env.reddit_client_secret}`,
14 ).toString("base64");
15 const response = await fetch("https://www.reddit.com/api/v1/access_token", {
16 method: "POST",
17 body: formData,

authenticateRedditmain.tsx2 matches

@mschleske•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { Buffer } from "node:buffer";
3
24
25 try {
26 response = await fetch("https://www.reddit.com/api/v1/access_token", {
27 headers: headers,
28 method: "POST",

addShortlinkmain.tsx4 matches

@byjp•Updated 1 year ago
1import { shortlink_domain } from "https://esm.town/v/byjp/shortlink_domain";
2import { shortlink_repo } from "https://esm.town/v/byjp/shortlink_repo";
3import { fetch } from "https://esm.town/v/std/fetch";
4import { Buffer } from "node:buffer";
5
18 return;
19 }
20 const check = await fetch(
21 `https://${shortlink_domain}${shortlink}`,
22 {
54 };
55 const path = `https://api.github.com/repos/${shortlink_repo}/contents/public/_redirects`;
56 const getRes = await fetch(path, {
57 method: "GET",
58 headers,
80 let redirects = atob(ghJson.content);
81 redirects = `${shortlink} ${to} 302\n${redirects}`;
82 const putRes = await fetch(path, {
83 method: "PUT",
84 headers,

pollRSSFeedsmain.tsx3 matches

@iakovos•Updated 1 year ago
1import { chunk as chunk2 } from "https://esm.town/v/iakovos/chunk";
2import { fetchAndParseFeeds } from "https://esm.town/v/iakovos/fetchAndParseFeeds";
3import { lastRunAt } from "https://esm.town/v/iakovos/lastRunAt";
4import { rssFeeds } from "https://esm.town/v/iakovos/rssFeeds";
10 await Promise.all(chunk.map(async ({ name, url, type }) => {
11 try {
12 const feeds = await fetchAndParseFeeds(url) || [];
13 const newFeeds = feeds.filter(({ pubDate }) =>
14 lastRunAt
20 }
21 catch (error) {
22 console.error(`Failed to fetch items for ${name}: ${error.message}!`);
23 }
24 }));

fetchPaginatedData2 file matches

@nbbaier•Updated 2 weeks ago

FetchBasic1 file match

@fredmoon•Updated 2 weeks ago