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/$1?q=fetch&page=1073&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 12878 results for "fetch"(5260ms)

nasaImageDetailsmain.tsx2 matches

@wallek•Updated 11 months ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export const nasaImageDetails = async () => {
4 const nasaAPOD = await fetchJSON("https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY");
5 let nasaImageHtml = nasaAPOD.hdurl
6 ? `<img width="100%" src="${nasaAPOD.hdurl}"/>`

getYenPriceCronmain.tsx6 matches

@kayla_lin•Updated 11 months ago
1import { blob } from "https://esm.town/v/std/blob";
2import { fetch } from "https://esm.town/v/std/fetch";
3import xml2js from "npm:xml2js";
4
5async function fetchHistoricData() {
6 const currentDate = new Date();
7 const promises = [];
14 `https://www.floatrates.com/historical-exchange-rates.html?operation=rates&pb_id=1462&page=historical&currency_date=${formattedDate}&base_currency_code=JPY&format_type=xml`;
15
16 const fetchPromise = fetch(url)
17 .then((response) => {
18 if (!response.ok) {
40 .catch((error) => {
41 console.error(
42 "There has been a problem with your fetch operation:",
43 error,
44 );
46 });
47
48 promises.push(fetchPromise);
49 }
50
61
62export default async function(interval: Interval) {
63 const history = await fetchHistoricData();
64
65 await blob.setJSON("daily", history);

qdrantmain.tsx1 match

@dglazkov•Updated 11 months ago
30 const qdrantUrl = `https://${cluster_id}.cloud.qdrant.io${path}`;
31
32 const response = await fetch(qdrantUrl, {
33 method: req.method,
34 headers: req.headers,

fetchJSONmain.tsx5 matches

@maxm•Updated 11 months ago
1import { normalizeURL } from "https://esm.town/v/stevekrouse/normalizeURL";
2
3export const fetchJSON = async (
4 url: string | URL,
5 options?: RequestInit & {
6 bearer?: string;
7 fetch?: typeof fetch;
8 },
9) => {
17 headers.set("traceparent", traceparent);
18 }
19 let fetch = options?.fetch ?? globalThis.fetch;
20 let resp = await fetch(normalizeURL(url), {
21 redirect: "follow",
22 ...options,
28 }
29 catch (e) {
30 throw new Error(`fetchJSON error: ${e.message} in ${url}\n\n"${text}"`);
31 }
32};

uptimemain.tsx2 matches

@stevekrouse•Updated 11 months ago
11 const start = performance.now();
12 try {
13 const res = await fetch(url);
14 end = performance.now();
15 status = res.status;
22 } catch (e) {
23 end = performance.now();
24 reason = `couldn't fetch: ${e}`;
25 ok = false;
26 console.log(`Website down (${url}): ${reason} (${end - start}ms)`);

bookReservationOnResymain.tsx7 matches

@fshine99•Updated 11 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const bookReservationOnResy = async ({
145 )
146 }&password=${encodeURIComponent(params.password)}`;
147 const response = await fetch(`${RESY_API_URL}/3/auth/password`, {
148 method: "POST",
149 body: body,
167 }) => {
168 const url = `${RESY_API_URL}/3/details`;
169 const response = await fetch(url.toString(), {
170 method: "POST",
171 headers: RESY_DEFAULT_HEADERS,
192 searchParams.set("party_size", params.seats.toString());
193 searchParams.set("venue_id", params.venueId);
194 const response = await fetch(`${url}?${searchParams}`, {
195 method: "GET",
196 headers: RESY_DEFAULT_HEADERS,
212 searchParams.set("url_slug", params.slug);
213 searchParams.set("location", params.city);
214 const response = await fetch(`${url}?${searchParams}`, {
215 method: "GET",
216 headers: RESY_DEFAULT_HEADERS,
224 authToken: string;
225 }) => {
226 const response = await fetch(`${RESY_API_URL}/3/book`, {
227 method: "POST",
228 headers: {
252 venueId,
253 });
254 console.log("Fetched available slots for day", {
255 count: slots.length,
256 times: slots.map((slot) => `${slot.date.start} -> ${slot.date.end}`),

umbrellaRemindermain.tsx2 matches

@madhatter349•Updated 11 months ago
1import { email } from "https://esm.town/v/std/email?v=9";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3import { nominatimSearch } from "https://esm.town/v/stevekrouse/nominatimSearch";
4import { weatherGovGrid } from "https://esm.town/v/stevekrouse/weatherGovGrid";
14 lon,
15 });
16 let { properties: { periods } } = await fetchJSON(
17 grid.forecastHourly,
18 );

multiplayerCirclesmain.tsx2 matches

@Llad•Updated 11 months ago
86 const y = d3.select(this).attr("cy");
87
88 fetch(`/update?x=${x}&y=${y}&i=${d3.select(this).attr("idx")}`, { method: "post" });
89 d3.select(this).attr("stroke", null);
90 }
190 return new Response(body, { headers: { "Content-Type": "text/event-stream" } });
191});
192export default app.fetch;

blobmain.tsx4 matches

@natashatherobot•Updated 11 months 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")}`,
124
125async function set(key: string, value: BodyInit) {
126 const res = await fetch(`${API_URL}/v1/blob/${encodeURIComponent(key)}`, {
127 method: "POST",
128 headers: {

blobbyFacemain.tsx15 matches

@rupello•Updated 11 months ago
2import { blobby } from "https://esm.town/v/yawnxyz/blobby";
3import { fileTypeFromBuffer } from 'npm:file-type';
4import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
5import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth?v=74";
6
66
67
68// Endpoint to fetch blob by key
69app.get("/blob/:key", async (c) => {
70 const key = c.req.param('key');
193 this.blobs[key] = {isLoading: true};
194
195 const response = await fetch('/blob/' + key);
196 const contentType = response.headers.get('Content-Type');
197 blob.type = contentType || 'text/plain';
223 let blob = this.blobs[key];
224 try {
225 const response = await fetch('/create/' + key, {
226 method: 'POST',
227 headers: {
247
248 // Send a delete request to the server
249 const response = await fetch('/delete/' + key, { method: 'GET' });
250
251 // Check the response status
313
314 try {
315 const response = await fetch('/upload/' + key, {
316 method: 'POST',
317 body: formData,
338
339 try {
340 const response = await fetch('/uploadUrl' + '?key=' + key + '&url=' + url);
341
342 if (!response.ok) {
361 if (!this.newKeyName) return;
362 try {
363 const response = await fetch('/rename?key='+key+'&newKey='+this.newKeyName);
364 if (!response.ok) {
365 throw new Error('Failed to rename blob');
526 async loadBlob() {
527 this.isLoading = true;
528 const response = await fetch('/blob/' + this.key);
529 const contentType = response.headers.get('Content-Type');
530 this.blobType = contentType || 'text/plain';
550 async updateCreate() {
551 try {
552 const response = await fetch('/create/' + this.key, {
553 method: 'POST',
554 headers: {
573
574 try {
575 const response = await fetch('/upload/' + this.key, {
576 method: 'POST',
577 body: formData,
593 if (this.uploadUrl) {
594 try {
595 const response = await fetch('/uploadUrl?key=' + this.key + '&url=' + this.uploadUrl);
596
597 if (!response.ok) {
610 if (!this.newKeyName) return;
611 try {
612 const response = await fetch('/rename?key=' + this.key + '&newKey=' + this.newKeyName);
613 if (!response.ok) {
614 throw new Error('Failed to rename blob');
707
708
709// export default app.fetch;
710export default passwordAuth(app.fetch, {
711 // password: "123", // Deno.env.get("AUTH_TEST"),
712});

fetch-socials4 file matches

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

fetchRssForSubcurrent2 file matches

@ashryanio•Updated 2 days ago