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=704&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 8406 results for "fetch"(1229ms)

untitled_magentaQuailmain.tsx4 matches

@shiann3•Updated 1 year ago
6import { email } from "";
7
8// Fetches a random joke.
9async function fetchRandomJoke() {
10 const response = await fetch(
11 "https://official-joke-api.appspot.com/random_joke",
12 );
13 return response.json();
14}
15const randomJoke = await fetchRandomJoke();
16const setup = randomJoke.setup;
17const punchline = randomJoke.punchline;

getMemain.tsx2 matches

@stevekrouse•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export function getMe(): Promise<{ username: string; id: string; profileImageUrl; bio: string }> {
4 return fetchJSON("https://api.val.town/v1/me", {
5 headers: {
6 Authorization: `Bearer ${Deno.env.get("valtown")}`,

codeOnValTownREADME.md6 matches

@andreterron•Updated 1 year ago
11Here are 2 different ways to add the "Code on Val Town" ribbon:
12
13### 1. Wrap your fetch handler (recommended)
14
15```ts
16import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
17import { html } from "https://esm.town/v/stevekrouse/html?v=5";
18
19export default modifyFetchHandler(async (req: Request): Promise<Response> => {
20 return html(`<h2>Hello world!</h2>`);
21});
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`
54- `modifyHtmlString("<html>...", {val: { handle: "andre", name: "foo" }})`
55
58You can set the style parameter to a css string to customize the ribbon. Check out [github-fork-ribbon-css](https://github.com/simonwhitaker/github-fork-ribbon-css?tab=readme-ov-file#styling) to learn more about how to style the element.
59
60- `modifyFetchHandler(handler, {style: ".github-fork-ribbon:before { background-color: #333; }"})`
61- `modifyHtmlString("<html>...", {style: ".github-fork-ribbon:before { background-color: #333; }"})`
62
64
65```ts
66modifyFetchHandler(handler, {style: `@media (max-width: 768px) {
67 .github-fork-ribbon {
68 display: none !important;

refreshAnimalWidgetmain.tsx2 matches

@crsven•Updated 1 year ago
1import { animalWidgetJson } from "https://esm.town/v/crsven/animalWidgetJson";
2import { fetchABird } from "https://esm.town/v/crsven/fetchABird";
3import { getBirdPhotoUrl } from "https://esm.town/v/crsven/getBirdPhotoUrl";
4import { getNextColorCombo } from "https://esm.town/v/crsven/getNextColorCombo";
6
7export let refreshAnimalWidget = async () => {
8 const bird = await fetchABird();
9 const photoUrl = await getBirdPhotoUrl(
10 `${bird.gen} ${bird.sp}`,

market_kelly_betmain.tsx2 matches

@case•Updated 1 year ago
35
36async function getMarket(slug: string) {
37 const res = await fetch(`https://api.manifold.markets/v0/slug/${slug}`);
38
39 if (!res.ok) {
40 const body = await res.text();
41 throw new Error(body ?? "Error fetching market");
42 }
43

getThreadsActivitymain.tsx1 match

@glommer•Updated 1 year ago
20
21async function getNewThreads() {
22 const resp = await fetch(`https://discord.com/api/guilds/${guild}/threads/active`, {
23 headers: {
24 "Authorization": `Bot ${token}`,

val2imgmain.tsx1 match

@pomdtr•Updated 1 year ago
7 const title = `@${author}/${name}`;
8
9 const resp = await fetch(`https://api.val.town/v1/alias/${author}/${name}`, {
10 headers: {
11 Authorization: `Bearer ${Deno.env.get("valtown")}`,

rpcREADME.md2 matches

@zarutian•Updated 1 year ago
39
40```ts
41const res = await fetch("https://std-rpc_example.web.val.run/?args=[2,3]");
42console.log(await res.json()); // 5
43```
46
47```ts
48const res = await fetch("https://std-rpc_example.web.val.run/", {
49 method: "POST",
50 body: JSON.stringify({ args: [2, 3] })

blogmain.tsx1 match

@pomdtr•Updated 1 year ago
71}
72
73export const blog = app.fetch;
74
75// #blog

emailCourseCreatormain.tsx6 matches

@petermillspaugh•Updated 1 year ago
1import { fetchConfirmationHtml } from "https://esm.town/v/petermillspaugh/fetchConfirmationHtml";
2import { fetchSignupHtml } from "https://esm.town/v/petermillspaugh/fetchSignupHtml";
3import { markLessonComplete } from "https://esm.town/v/petermillspaugh/markLessonComplete";
4import { refreshToken } from "https://esm.town/v/petermillspaugh/refreshToken";
16
17 app.get("/", async (c) => {
18 return c.html(fetchSignupHtml());
19 });
20
32
33 // Lack of await is intentional: send optimistic success response, then send email and notify myself async
34 sendVerification({ emailAddress: email, html: fetchConfirmationHtml({ email, token }) });
35
36 return Response.json({ success: true, message: "Sent verification email." });
46 sendVerification({
47 emailAddress: email,
48 html: fetchConfirmationHtml({ email, token: newToken, reVerifying: true }),
49 });
50
102 });
103
104 return app.fetch(req);
105}

fetchPaginatedData2 file matches

@nbbaier•Updated 2 weeks ago

FetchBasic1 file match

@fredmoon•Updated 2 weeks ago