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=688&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 8641 results for "fetch"(1633ms)

serve_routermain.tsx1 match

@yieldray•Updated 1 year ago
24 .get("/two", () => new Response("two"));
25
26export const serve_router = app.fetch

redSpoonbillmain.tsx2 matches

@Joelsrubin•Updated 1 year ago
1export async function getTopTenBattingAverage() {
2 const data = await fetch(
3 "http://sports.core.api.espn.com/v2/sports/baseball/leagues/mlb/seasons/2024/types/2/leaders?lang=en&region=us",
4 );
7 .map((
8 l,
9 ) => fetch(l).then(response => response.json()));
10
11 const finalList = await Promise.all(promises);

ctanPackageNamesmain.tsx1 match

@aleaf•Updated 1 year ago
1export default async function(req: Request): Promise<Response> {
2 const response = await fetch("https://ctan.org/json/2.0/packages");
3 const packages = await response.json();
4 const output = packages.map(item => item.name).join("\n");

msw_examplemain.tsx3 matches

@vladimyr•Updated 1 year ago
1import { http } from "npm:msw";
2// import { setupWorker } from "npm:msw/browser";
3import { handler } from "https://esm.town/v/postpostscript/fetchWorkerExample?v=39";
4import { setupServer } from "npm:msw/node";
5
9server.listen();
10
11// @see: https://www.val.town/v/postpostscript/fetchWorkerExample?v=39#L18-27
12const resp = await fetch("/", {
13 method: "POST",
14 body: JSON.stringify({

fetchWorkermain.tsx2 matches

@postpostscript•Updated 1 year ago
6workerURL.searchParams.set("worker", "1");
7
8export async function fetchWorker(opts: {
9 url: string;
10 handler?: string;
49
50 return {
51 fetch: async (input: URL | RequestInfo, init?: RequestInit) => {
52 const req = new Request(input, init);
53

fetchWorkerREADME.md8 matches

@postpostscript•Updated 1 year ago
1# fetchWorker: communicate with a worker over a `fetch`-like interface!
2
3## Example:
4
5```ts
6import { fetchWorker } from "https://esm.town/v/postpostscript/fetchWorker";
7
8using worker = await fetchWorker({
9 url: "https://esm.town/v/postpostscript/fetchWorkerExample",
10 handler: "handler",
11});
12
13const res = await worker.fetch("/", {
14 method: "POST",
15 body: JSON.stringify({
31```
32
33[Full Example](fetchWorkerExample)
34
35## Options:
36
37- `url` (`string`, required): URL that the worker will fetch the handler from
38- `handler` (`string`, defaults to `default`): name of export that will execute the request
39
40Migrated from folder: Worker/fetchWorker

MoonPhasemain.tsx2 matches

@sethblanchard•Updated 1 year ago
1/** @jsxImportSource npm:react **/
2import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=6";
3import { load } from "npm:cheerio";
4import { renderToString } from "npm:react-dom@18/server";
5
6export default async (req: Request) => {
7 const html = await fetchText(
8 "https://www.moongiant.com/phase/today/",
9 );

extractJSDocmain.tsx2 matches

@pomdtr•Updated 1 year ago
3 */
4
5import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=6";
6import { parse } from "npm:comment-parser";
7
19
20async function extractJSDocfromURL(url: string) {
21 const text = await fetchText(url);
22 return extractJSDocfromText(text);
23}

isMyWebsiteDownmain.tsx2 matches

@omaismoe•Updated 1 year ago
12 let reason: string;
13 try {
14 const res = await fetch(URL, { redirect: "follow" });
15 if (res.status !== 200) {
16 reason = `(status code: ${res.status})`;
18 }
19 } catch (e) {
20 reason = `couldn't fetch: ${e}`;
21 ok = false;
22 }

dataURL_examplemain.tsx1 match

@vladimyr•Updated 1 year ago
9console.log(dataURL1);
10
11const resp = await fetch(dataURL1);
12const text = await resp.text();
13console.assert(resp.headers.get("content-type") === "text/plain");

fetchPaginatedData2 file matches

@nbbaier•Updated 3 weeks ago

FetchBasic1 file match

@fredmoon•Updated 3 weeks ago