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%20%22Image%20title%22?q=fetch&page=727&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 8864 results for "fetch"(3734ms)

nasaAPODmain.tsx2 matches

@henrii•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 = await fetchJSON("https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY");
5console.log(nasaAPOD.url);
6

fetchAndStoreOpenAiUsage2README.md1 match

@nbbaier•Updated 1 year ago
1Migrated from folder: projects/OpenAiUsage/fetchAndStoreOpenAiUsage2

fetchNewPublicGitHubReposmain.tsx3 matches

@stevekrouse•Updated 1 year ago
1export default async function fetchNewPublicGitHubRepos() {
2 // Generate today's date in YYYY-MM-DD format
3 const today = new Date().toISOString().split("T")[0];
9 const url = `https://api.github.com/search/repositories?q=${encodeURIComponent(query)}&sort=${sort}&order=${order}`;
10
11 const response = await fetch(url, {
12 headers: {
13 "Accept": "application/vnd.github.v3+json",
14 "User-Agent": "Deno-GitHub-Repo-Fetcher", // GitHub API requires a user-agent header
15 },
16 });

fetchNewPublicGitHubReposREADME.md1 match

@stevekrouse•Updated 1 year ago
1Migrated from folder: Archive/fetchNewPublicGitHubRepos

http_request_examplemain.tsx11 matches

@pomdtr•Updated 1 year ago
4 */
5
6// To make a request to a server, you use the `fetch` API.
7let resp = await fetch("https://example.com");
8
9// The response is a `Response` object. This contains the status code, headers,
15// The response body can also be read as JSON, an ArrayBuffer, or a Blob. A body
16// can be read only once.
17resp = await fetch("https://example.com");
18await resp.arrayBuffer();
19/** or await resp.json(); */
21
22// The response body can also be streamed in chunks.
23resp = await fetch("https://example.com");
24for await (const chunk of resp.body!) {
25 console.log("chunk", chunk);
28// When making a request, you can also specify the method, headers, and a body.
29const body = `{"name": "Deno"}`;
30resp = await fetch("https://example.com", {
31 method: "POST",
32 headers: {
37});
38
39// `fetch` also accepts a `Request` object instead of URL + options.
40const req = new Request("https://example.com", {
41 method: "DELETE",
42});
43resp = await fetch(req);
44
45// Instead of a string, the body can also be any typed array, blob, or
59});
60
61// Forms can also be sent with `fetch` by using a `FormData` object as the body.
62const formData = new FormData();
63formData.append("name", "Deno");
64formData.append("file", new Blob(["Hello, World!"]), "hello.txt");
65resp = await fetch("https://example.com", {
66 method: "POST",
67 body: formData,
68});
69
70// Fetch also supports streaming the request body.
71const bodyStream = new ReadableStream({
72 start(controller) {
75 },
76});
77resp = await fetch("https://example.com", {
78 method: "POST",
79 body: bodyStream,

fetsServerExamplemain.tsx1 match

@maxm•Updated 1 year ago
21});
22
23export default router.fetch;

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());

fetchPaginatedData2 file matches

@nbbaier•Updated 3 weeks ago

FetchBasic1 file match

@fredmoon•Updated 3 weeks ago