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=1150&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 13096 results for "fetch"(2648ms)

setmain.tsx2 matches

@pomdtr•Updated 1 year ago
1import { API_URL } from "https://esm.town/v/std/API_URL";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3import process from "node:process";
4
5export async function set(key: string, value: any) {
6 let resp = await fetch(
7 `${API_URL}/v1/vals`,
8 {

blobmain.tsx4 matches

@vladimyr•Updated 1 year ago
82async function list(prefix?: string): Promise<{ key: string; size: number; lastModified: string }[]> {
83 let querystring = prefix ? `?prefix=${encodeURIComponent(prefix)}` : "";
84 const res = await fetch(`${API_URL}/v1/blob${querystring}`, {
85 headers: {
86 Authorization: `Bearer ${Deno.env.get("valtown")}`,
95
96async function delete_(key: string) {
97 const res = await fetch(`${API_URL}/v1/blob/${encodeURIComponent(key)}`, {
98 method: "DELETE",
99 headers: {
108
109async function get(key: string) {
110 const res = await fetch(`${API_URL}/v1/blob/${encodeURIComponent(key)}`, {
111 headers: {
112 Authorization: `Bearer ${Deno.env.get("valtown")}`,
127 value = value.body;
128 }
129 const res = await fetch(`${API_URL}/v1/blob/${encodeURIComponent(key)}`, {
130 method: "POST",
131 headers: {

TODO_tootLatestPostsmain.tsx4 matches

@jaandrle•Updated 1 year ago
9 "https://jaandrle.github.io/feeds/nondev.xml",
10 "https://jaandrle.github.io/feeds/dev.xml",
11 ].map(fetchRSS)))
12 .flatMap(rss =>
13 rss.entry
23}
24
25import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
26import { parseXML } from "https://esm.town/v/stevekrouse/parseXML";
27function fetchRSS(url) {
28 return fetchText(url)
29 .then(parseXML)
30 .then(xml => {

blobSetResponseBodyExamplemain.tsx1 match

@stevekrouse•Updated 1 year ago
3const url = "https://example.com";
4const key = "exampleBlob";
5await blob.set(key, (await fetch(url)).body);
6console.log(await (await blob.get(key)).text());

blobSetResponseBodyExampleREADME.md1 match

@stevekrouse•Updated 1 year ago
1# Set Blob Storage via fetch Response body
2
3Inspired by [Wes Bos's tweet](https://twitter.com/wesbos/status/1775558324454392064?t=Pnx8jDyfF7wVbZJp0QnNJw&s=19) about Bun's elegant Filesystem API.

fireworks_ai_proxymain.tsx1 match

@taras•Updated 1 year ago
90 // console.log(init);
91 // console.log(init.body);
92 const response = await fetch(url.toString(), init);
93 const responseHeaders = new Headers(response.headers);
94 // Special handling for /api/v1/models

cors_proxymain.tsx2 matches

@taras•Updated 1 year ago
52 };
53
54 // Perform the fetch request to the destination URL
55 const response = await fetch(destUrlString, init);
56
57 // Return the response from the destination URL, including CORS headers

getHashForUrlmain.tsx3 matches

@vladimyr•Updated 1 year ago
3// Retrieves the URL, and returns a hash of its contents.
4export async function getHashForUrl(url: string): Promise<string> {
5 // Fetch the content from the URL
6 const response = await fetch(url);
7 if (!response.ok) {
8 throw new Error(`Failed to fetch URL: ${url}`);
9 }
10 const data = await response.arrayBuffer();

fetch_docsmain.tsx6 matches

@andreterron•Updated 1 year ago
2
3/**
4 * Wraps the JavaScript Fetch function to anonymize where the request is
5 * coming from ([Docs ↗](https://docs.val.town/std/fetch))
6 *
7 * @param {string | URL | Request} input - The resource to fetch.
8 * @param {RequestInit} [requestInit] - Optional configuration data (HTTP
9 * method, headers, etc) ([Docs ↗](https://deno.land/api@v1.42.1?s=RequestInit))
10 */
11export async function fetch(input: string | URL | Request, requestInit?: RequestInit) {
12 const origReq = new Request(input, requestInit);
13 const url = new URL("/v1/fetch", API_URL);
14 url.searchParams.set("url", origReq.url);
15 const req = new Request(url, origReq);
16 req.headers.set("X-Valtown-Authorization", `Bearer ${Deno.env.get("valtown")}`);
17 return globalThis.fetch(req);
18}

fetchmain.tsx6 matches

@vladimyr•Updated 1 year ago
2
3/**
4 * Wraps the JavaScript Fetch function to anonymize where the request is
5 * coming from ([Docs ↗](https://docs.val.town/std/fetch))
6 *
7 * @param {string | URL | Request} input - The resource to fetch.
8 * @param {RequestInit} [requestInit] - Optional configuration data (HTTP
9 * method, headers, etc) ([Docs ↗](https://deno.land/api@v1.42.1?s=RequestInit))
10 */
11export async function fetch(input: string | URL | Request, requestInit?: RequestInit) {
12 const origReq = new Request(input, requestInit);
13 const url = new URL("/v1/fetch", API_URL);
14 url.searchParams.set("url", origReq.url);
15 const req = new Request(url, origReq);
16 req.headers.set("X-Valtown-Authorization", `Bearer ${Deno.env.get("valtown")}`);
17 return globalThis.fetch(req);
18}

fetch-socials4 file matches

@welson•Updated 3 days ago
fetch and archive my social posts

fetchRssForSubcurrent2 file matches

@ashryanio•Updated 3 days ago