nasaImageDetailsmain.tsx2 matches
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
23export const nasaImageDetails = async () => {
4const nasaAPOD = await fetchJSON("https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY");
5let nasaImageHtml = nasaAPOD.hdurl
6? `<img width="100%" src="${nasaAPOD.hdurl}"/>`
getYenPriceCronmain.tsx6 matches
1import { blob } from "https://esm.town/v/std/blob";
2import { fetch } from "https://esm.town/v/std/fetch";
3import xml2js from "npm:xml2js";
45async function fetchHistoricData() {
6const currentDate = new Date();
7const promises = [];
14`https://www.floatrates.com/historical-exchange-rates.html?operation=rates&pb_id=1462&page=historical¤cy_date=${formattedDate}&base_currency_code=JPY&format_type=xml`;
1516const fetchPromise = fetch(url)
17.then((response) => {
18if (!response.ok) {
40.catch((error) => {
41console.error(
42"There has been a problem with your fetch operation:",
43error,
44);
46});
4748promises.push(fetchPromise);
49}
506162export default async function(interval: Interval) {
63const history = await fetchHistoricData();
6465await blob.setJSON("daily", history);
30const qdrantUrl = `https://${cluster_id}.cloud.qdrant.io${path}`;
3132const response = await fetch(qdrantUrl, {
33method: req.method,
34headers: req.headers,
1import { normalizeURL } from "https://esm.town/v/stevekrouse/normalizeURL";
23export const fetchJSON = async (
4url: string | URL,
5options?: RequestInit & {
6bearer?: string;
7fetch?: typeof fetch;
8},
9) => {
17headers.set("traceparent", traceparent);
18}
19let fetch = options?.fetch ?? globalThis.fetch;
20let resp = await fetch(normalizeURL(url), {
21redirect: "follow",
22...options,
28}
29catch (e) {
30throw new Error(`fetchJSON error: ${e.message} in ${url}\n\n"${text}"`);
31}
32};
11const start = performance.now();
12try {
13const res = await fetch(url);
14end = performance.now();
15status = res.status;
22} catch (e) {
23end = performance.now();
24reason = `couldn't fetch: ${e}`;
25ok = false;
26console.log(`Website down (${url}): ${reason} (${end - start}ms)`);
bookReservationOnResymain.tsx7 matches
1import { fetch } from "https://esm.town/v/std/fetch";
23export const bookReservationOnResy = async ({
145)
146}&password=${encodeURIComponent(params.password)}`;
147const response = await fetch(`${RESY_API_URL}/3/auth/password`, {
148method: "POST",
149body: body,
167}) => {
168const url = `${RESY_API_URL}/3/details`;
169const response = await fetch(url.toString(), {
170method: "POST",
171headers: RESY_DEFAULT_HEADERS,
192searchParams.set("party_size", params.seats.toString());
193searchParams.set("venue_id", params.venueId);
194const response = await fetch(`${url}?${searchParams}`, {
195method: "GET",
196headers: RESY_DEFAULT_HEADERS,
212searchParams.set("url_slug", params.slug);
213searchParams.set("location", params.city);
214const response = await fetch(`${url}?${searchParams}`, {
215method: "GET",
216headers: RESY_DEFAULT_HEADERS,
224authToken: string;
225}) => {
226const response = await fetch(`${RESY_API_URL}/3/book`, {
227method: "POST",
228headers: {
252venueId,
253});
254console.log("Fetched available slots for day", {
255count: slots.length,
256times: slots.map((slot) => `${slot.date.start} -> ${slot.date.end}`),
umbrellaRemindermain.tsx2 matches
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";
14lon,
15});
16let { properties: { periods } } = await fetchJSON(
17grid.forecastHourly,
18);
multiplayerCirclesmain.tsx2 matches
86const y = d3.select(this).attr("cy");
8788fetch(`/update?x=${x}&y=${y}&i=${d3.select(this).attr("idx")}`, { method: "post" });
89d3.select(this).attr("stroke", null);
90}
190return new Response(body, { headers: { "Content-Type": "text/event-stream" } });
191});
192export default app.fetch;
82async function list(prefix?: string): Promise<{ key: string; size: number; lastModified: string }[]> {
83let querystring = prefix ? `?prefix=${encodeURIComponent(prefix)}` : "";
84const res = await fetch(`${API_URL}/v1/blob${querystring}`, {
85headers: {
86Authorization: `Bearer ${Deno.env.get("valtown")}`,
9596async function delete_(key: string) {
97const res = await fetch(`${API_URL}/v1/blob/${encodeURIComponent(key)}`, {
98method: "DELETE",
99headers: {
108109async function get(key: string) {
110const res = await fetch(`${API_URL}/v1/blob/${encodeURIComponent(key)}`, {
111headers: {
112Authorization: `Bearer ${Deno.env.get("valtown")}`,
124125async function set(key: string, value: BodyInit) {
126const res = await fetch(`${API_URL}/v1/blob/${encodeURIComponent(key)}`, {
127method: "POST",
128headers: {
blobbyFacemain.tsx15 matches
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";
6666768// Endpoint to fetch blob by key
69app.get("/blob/:key", async (c) => {
70const key = c.req.param('key');
193this.blobs[key] = {isLoading: true};
194
195const response = await fetch('/blob/' + key);
196const contentType = response.headers.get('Content-Type');
197blob.type = contentType || 'text/plain';
223let blob = this.blobs[key];
224try {
225const response = await fetch('/create/' + key, {
226method: 'POST',
227headers: {
247248// Send a delete request to the server
249const response = await fetch('/delete/' + key, { method: 'GET' });
250251// Check the response status
313
314try {
315const response = await fetch('/upload/' + key, {
316method: 'POST',
317body: formData,
338
339try {
340const response = await fetch('/uploadUrl' + '?key=' + key + '&url=' + url);
341
342if (!response.ok) {
361if (!this.newKeyName) return;
362try {
363const response = await fetch('/rename?key='+key+'&newKey='+this.newKeyName);
364if (!response.ok) {
365throw new Error('Failed to rename blob');
526async loadBlob() {
527this.isLoading = true;
528const response = await fetch('/blob/' + this.key);
529const contentType = response.headers.get('Content-Type');
530this.blobType = contentType || 'text/plain';
550async updateCreate() {
551try {
552const response = await fetch('/create/' + this.key, {
553method: 'POST',
554headers: {
573574try {
575const response = await fetch('/upload/' + this.key, {
576method: 'POST',
577body: formData,
593if (this.uploadUrl) {
594try {
595const response = await fetch('/uploadUrl?key=' + this.key + '&url=' + this.uploadUrl);
596597if (!response.ok) {
610if (!this.newKeyName) return;
611try {
612const response = await fetch('/rename?key=' + this.key + '&newKey=' + this.newKeyName);
613if (!response.ok) {
614throw new Error('Failed to rename blob');
707708709// export default app.fetch;
710export default passwordAuth(app.fetch, {
711// password: "123", // Deno.env.get("AUTH_TEST"),
712});