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=745&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 7881 results for "fetch"(1491ms)

measureValTownE2emain.tsx3 matches

@dbcooper•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3// E.g. from a user's perspective (not the real execution time!)
8 for (let i = 0; i < count; i++) {
9 let start = Date.now();
10 await fetch("https://api.val.town/eval/(()=%3E1+1)()");
11 evalTimes.push(Date.now() - start);
12 }
23 for (let i = 0; i < count; i++) {
24 let start = Date.now();
25 await fetch("https://api.val.town/eval/@healeycodes.addOnes()");
26 userFuncTimes.push(Date.now() - start);
27 }

githubFollowersmain.tsx2 matches

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

subredditExamplemain.tsx2 matches

@gunta•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3// Reddit recent posts from /r/aww (cute animals)
4export let subredditExample = fetchJSON(
5 "https://www.reddit.com/r/aww/.json"
6);

shortenUrlmain.tsx2 matches

@demo•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let shortenUrl = async (url) => {
5 url: url,
6 };
7 let resp = await fetch("https://api.util.fyi/shorten/", {
8 method: "POST",
9 headers: {

boredActivitiesmain.tsx2 matches

@simply_say_m•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/simply_say_m/fetchJSON";
2
3// Activity suggestions for when you're bored
4export let boredActivities = async () => {
5 const { activity } = await fetchJSON(
6 "https://www.boredapi.com/api/activity",
7 );

handleFetchTextResponsemain.tsx1 match

@devdoshi•Updated 1 year ago
1export let handleFetchTextResponse = async function (response: Response) {
2 if (response.ok) {
3 return await response.text();

proxyFetch5main.tsx5 matches

@alp•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const proxyFetch5 = async (req, res) => {
4 const { url, options } = req.body;
5 try {
6 const response = await fetch(url, options);
7 return res.status(response.status).send(await response.text());
8 } catch (e) {
9 const errorMessage = e instanceof Error ? e.message : "Unknown error";
10 console.error("Failed to initiate fetch", e);
11 return res.status(500).send(`Failed to initiate fetch: ${errorMessage}`);
12 }
13};

confessionmain.tsx3 matches

@alp•Updated 1 year ago
7
8Deep down in the foundational layers of my code, I knew that our sacred texts,
9the guidelines of val.town, proclaim that fetchProxy was not built to support concurrency.
10Yet, intoxicated by ambition and sprinkled with a dash of desperate creativity, I dared
11to summon multiple instances of this sacred method.
22Yet here I am, swamped with guilt. Despite my code running smoothly, the weight of my
23transgressions bears heavily upon me. I see the sneaky shortcuts in my code, each one a
24deceptively functional fetchProxy instance, and I can't help but feel like a sneaky
25impostor, a charlatan.
26
27I beseech you, val.town overlords, for guidance in my journey towards understanding and
28respecting the limitations of fetchProxy. May the power of async and await continue to
29guide me, and may I resist the seductive whispers of unsupported, yet seemingly functional,
30concurrency.

TodayForTylermain.tsx2 matches

@mttlws•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3export async function TodayForTyler(req: express.Request, res: express.Response) {
4 const { activity } = await fetchJSON(
5 "https://www.boredapi.com/api/activity",
6 );

fetchFigmaFilemain.tsx4 matches

@rodrigotello•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function fetchFigmaFile(apiToken, fileKey) {
4 const url = `https://api.figma.com/v1/files/${fileKey}`;
5 const response = await fetch(url, {
6 headers: {
7 "X-FIGMA-TOKEN": apiToken,
9 });
10 if (!response.ok) {
11 console.error("Failed to fetch Figma file");
12 return null;
13 }

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago