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=697&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 8496 results for "fetch"(1316ms)

purpleOctopusmain.tsx2 matches

@stevekrouse•Updated 1 year ago
1/** @jsxImportSource https://esm.sh/preact */
2import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
3import browse from "https://esm.town/v/stevekrouse/dateme_browse";
4import faq from "https://esm.town/v/stevekrouse/dateme_faq";
13app.all("/submit", form);
14app.get("/faq", faq);
15export default modifyFetchHandler(app.fetch, {
16 style: `@media (max-width: 500px) {
17 .github-fork-ribbon {

reloadOnSaveREADME.md3 matches

@stevekrouse•Updated 1 year ago
1# Reload in new tabs when your vals change
2
3When you're working on an HTML HTTP val in a new tab, it's annoying to have to manually reload the tab on every save. In the Val Town editor, you can hit cmd+enter, but there's nothing like that for a val in a new tab because Val Town doesn't control that new tab (like we control the iframe in the browser preview). However, you control that HTML via the fetch handler you're writing, so you can add a script that polls the Val Town API for the current version number of your val, and reload itself if it detects a new version. This val has a collection of helpers to help you do just that.
4
5## Usage
7```ts
8import { html } from "https://esm.town/v/stevekrouse/html";
9import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
10
11export default reloadOnSaveFetchMiddleware(async function(req: Request): Promise<Response> {
12 return html(`<h1>Hello!!</h1>`);
13})

JokeGeneratormain.tsx4 matches

@samarthpasala•Updated 1 year ago
1import { email } from "https://esm.town/v/std/email?v=9";
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
9}
10
11const randomJoke = await fetchRandomJoke();
12const setup = randomJoke.setup;
13const punchline = randomJoke.punchline;

pinkPigmain.tsx1 match

@stevekrouse•Updated 1 year ago
1// render WebcamPage as a client side react component with fetch handler response object
2
3const script = `

octopusAgilePricingmain.tsx3 matches

@MattieTK•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3type OctopusPrice = {
34 const octopusDataUrl =
35 `https://api.octopus.energy/v1/products/AGILE-BB-23-12-06/electricity-tariffs/E-1R-AGILE-BB-23-12-06-${locationCode}/standard-unit-rates/`;
36 const data = await fetch(octopusDataUrl);
37 let { results: results, next: next } = await data.json();
38 const now = results.filter((data) =>
41 );
42 if (now[0] == null) {
43 const nextData = await fetch(next);
44 let { results: results } = await nextData.json();
45 const nextNow = results.filter((data) =>

myPelotonWorkoutsmain.tsx2 matches

@andreterron•Updated 1 year ago
1import { fetchPelotonData } from "https://esm.town/v/andreterron/fetchPelotonData";
2import { blob } from "https://esm.town/v/std/blob?v=3";
3import { rpc } from "https://esm.town/v/std/rpc";
11 }
12 if (!pelotonCache || Date.now() > pelotonCache.time + 8 * 60 * 1000) {
13 const value = await fetchPelotonData();
14 pelotonCache = {
15 value,

plumGazellemain.tsx2 matches

@lufafajoshua•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function postHogAPICapture({ key, event, properties, distinct_id }: {
13 "distinct_id": distinct_id,
14 };
15 let result = await fetch("https://app.posthog.com/capture/", {
16 method: "POST",
17 headers: {
18 loadingDiv.style.display = 'block';
19
20 fetch(window.location.href, {
21 method: 'POST',
22 headers: {
96
97 // Send the POST request
98 const response = await fetch("https://dreaminterpreteraibackend.com/dream", {
99 method: "POST",
100 headers: {
110 "Sec-Ch-Ua-Mobile": "?0",
111 "Sec-Ch-Ua-Platform": "\"macOS\"",
112 "Sec-Fetch-Dest": "empty",
113 "Sec-Fetch-Mode": "cors",
114 "Sec-Fetch-Site": "cross-site",
115 "Uid": randomUuid(),
116 "User-Agent":

dot_commain.tsx1 match

@horatiothomas•Updated 1 year ago
31 if (url.pathname === "/favicon.ico") return new Response(null, { status: 404 });
32 if (url.pathname !== "/")
33 return fetch(
34 `https://stevekrouse.github.io/${url.pathname}${url.search}`,
35 request as any as RequestInit,

dream_interpretermain.tsx4 matches

@horatiothomas•Updated 1 year ago
73
74 // Send the POST request
75 const response = await fetch("https://dreaminterpreteraibackend.com/dream", {
76 method: "POST",
77 headers: {
87 "Sec-Ch-Ua-Mobile": "?0",
88 "Sec-Ch-Ua-Platform": "\"macOS\"",
89 "Sec-Fetch-Dest": "empty",
90 "Sec-Fetch-Mode": "cors",
91 "Sec-Fetch-Site": "cross-site",
92 "Uid": randomUuid(),
93 "User-Agent":

fetchPaginatedData2 file matches

@nbbaier•Updated 2 weeks ago

FetchBasic1 file match

@fredmoon•Updated 2 weeks ago