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/$%7Bsuccess?q=fetch&page=754&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 8348 results for "fetch"(2628ms)

test_dlockmain.tsx15 matches

@karfau•Updated 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

@cole•Updated 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

@stevekrouse•Updated 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

@stevekrouse•Updated 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

@frankdilo•Updated 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

@neverstew•Updated 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 },

runmain.tsx2 matches

@pomdtr•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { parseAuthorizationHeader } from "https://esm.town/v/pomdtr/parseAuthorizationHeader";
3
27 }
28 }
29 const resp = await fetch(url.toString(), {
30 method: req.method,
31 body: body || undefined,

storeTodaysDatemain.tsx2 matches

@tal•Updated 1 year ago
1import { fetchAndStore } from "https://esm.town/v/tal/fetchAndStore";
2import { currentDateValues } from "https://esm.town/v/tal/currentDateValues";
3
4export let storeTodaysDate = (async () => {
5 const today = currentDateValues();
6 await fetchAndStore({
7 ...today,
8 menuType: "pre-k---8-lunch-menu",

paginateAPImain.tsx3 matches

@andreterron•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3export const paginateAPI = async (
4 url: string,
5 options: Parameters<typeof fetch>[1],
6) => {
7 let result: any[] = [];
8 let nextUrl = url;
9 while (nextUrl) {
10 const { data, links } = await fetchJSON(
11 nextUrl,
12 options,

honoGameTestmain.tsx1 match

@andreterron•Updated 1 year ago
9 return c.html(html`<div style="background-color: pink;">Hello!</div>`);
10 });
11 return app.fetch(req);
12}

fetchPaginatedData2 file matches

@nbbaier•Updated 2 weeks ago

FetchBasic1 file match

@fredmoon•Updated 2 weeks ago