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/image-url.jpg?q=fetch&page=730&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 8667 results for "fetch"(1935ms)

nasaAPODmain.tsx2 matches

@danny•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3// Returns NASA's Astronomy Picture of the Day (APOD)
4export const nasaAPOD = fetchJSON("cutt.ly/T7ksirK");
5// Forked from @iBrokeit.nasaAPOD

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

fetchPaginatedData2 file matches

@nbbaier•Updated 3 weeks ago

FetchBasic1 file match

@fredmoon•Updated 3 weeks ago