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=729&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 8103 results for "fetch"(1514ms)

fetchCongressTradeReportsmain.tsx4 matches

@claytnUpdated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3/**
5 Receive daily emails of reported congress trades by scheduling a call to
6
7 @claytn.fetchCongressTradeReports((reports) => console.email(reports))
8*/
9
10
11export async function fetchCongressTradeReports(callback) {
12 const res = await fetchJSON(
13 "https://bff.capitoltrades.com/trades?sortBy=-pubDate"
14 );

checkBPPRequirementmain.tsx3 matches

@lbb00Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function checkBPPRequirement(imageUrl, minWidth, minHeight) {
4 try {
5 const response = await fetch(imageUrl);
6 const buffer = await response.arrayBuffer();
7 const totalPixels = minWidth * minHeight;
23 }
24 catch (error) {
25 console.error("❌ Error fetching image:", error.message);
26 }
27}

getTrainsmain.tsx3 matches

@briscoeUpdated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const getTrains = (async () => {
4 const skerries = await fetch(
5 "https://irish-rail-rest-api.fly.dev/stations/SKRES/timetable",
6 ).then((res) => res.json());
7 const connolly = await fetch(
8 "https://irish-rail-rest-api.fly.dev/stations/CNLLY/timetable",
9 ).then((res) => res.json());

getOpenMeteoForecastmain.tsx2 matches

@wiltUpdated 1 year ago
1import { toDatesWithTz } from "https://esm.town/v/wilt/toDatesWithTz";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
3
4// See https://open-meteo.com/en/docs for usage
92}
93export async function getOpenMeteoForecast(params: OMParams) {
94 const data = await fetchJSON(
95 `https://api.open-meteo.com/v1/forecast?${new URLSearchParams(
96 params as {} // Typescript is stricter than Deno here

test_dlockmain.tsx15 matches

@karfauUpdated 1 year ago
14 ),
15 ttl: 1,
16 fetchStub:
17 (data = {}, { status = 200, ok = status < 400 } = {}) => async () =>
18 Promise.resolve({ ok, status, json: async () => data } as const),
19 throwingFetchStub: async () => {
20 throw new Error("sync from test_dlock::throwingFetchStub");
21 },
22 ...await import("https://deno.land/std/assert/mod.ts"),
28 id,
29 ttl,
30 throwingFetchStub,
31 assertEquals,
32 assertRejects,
36 },
37 ) {
38 const fetchSpy = spy(throwingFetchStub);
39 const err = await assertRejects(() => dlock({ id, ttl }, fetchSpy));
40 assertEquals(err.message, "sync from test_dlock::throwingFetchStub");
41 assertSpyCalls(fetchSpy, 5);
42 assertSpyCall(fetchSpy, 4, {
43 args: [`https://dlock.univalent.net/lock/${id}/aquire?ttl=${ttl}`],
44 });
45 },
46 async function should_reject_ttl_of_0(
47 { dlock, id, ttl, fetchStub, assertMatch, assertRejects },
48 ) {
49 const err = await assertRejects(() => dlock({ id, ttl: 0 }, fetchStub()));
50 assertMatch(err.message, /ttl/);
51 },
52 async function should_return_lock_on_successful_request(
53 { dlock, deadline, fetchStub, assertFalse, assertEquals },
54 ) {
55 const lease = 375;
56 const lock = await dlock({}, fetchStub({ lease, deadline }));
57 assertEquals(lock.lease, lease, "lease");
58 assertEquals(lock.deadline, deadline, "deadline");
64 // runs into endless loop!
65 async function skip_should_reject_when_id_is_locked(
66 { dlock, id, ttl, deadline, fetchStub, assertRejects, assertEquals },
67 ) {
68 const error = "lock is acquired by another client";
69 const err = await assertRejects(() =>
70 dlock({ id, ttl }, fetchStub({ error, deadline }, { status: 409 }))
71 );
72 assertEquals(err.message, error);

fetchCatmain.tsx3 matches

@coleUpdated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let fetchCat = async () => {
4 const result = await fetch("https://aws.random.cat/meow");
5 const json = await result.json();
6 return json.file;

twitterJSONmain.tsx2 matches

@stevekrouseUpdated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export let twitterJSON = ({url, bearerToken}) => fetchJSON(
4 url,
5 {headers: {authorization: `Bearer ${bearerToken}`}}

fetchRSSmain.tsx3 matches

@stevekrouseUpdated 1 year ago
1import { parseXML } from "https://esm.town/v/stevekrouse/parseXML";
2import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
3
4export const fetchRSS = (url: string) =>
5 fetchText(url)
6 .then(parseXML)
7 .then(({ rss }) => rss);

convertCurrencymain.tsx3 matches

@frankdiloUpdated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3export let convertCurrency = async (desired, base = "usd", amount = 1) => {
4 let { rates } = await fetchJSON(
5 `https://open.er-api.com/v6/latest/${base}`,
6 );
8 return amount * (rates[desired.toUpperCase()]);
9 else {
10 let { rates } = await fetchJSON(
11 "https://api.coingecko.com/api/v3/exchange_rates",
12 );

valmain.tsx2 matches

@neverstewUpdated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3export function val({ token, id }: {
29 }
30 : {};
31 return fetchJSON(
32 "https://api.val.town/v1/vals/" + id,
33 { headers },

fetchPaginatedData2 file matches

@nbbaierUpdated 1 week ago

FetchBasic1 file match

@fredmoonUpdated 1 week ago