1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let fetchHeaders = (await fetch("https://swapi.dev/api/people/1/")).headers;
1import { runValAPIAuth } from "https://esm.town/v/stevekrouse/runValAPIAuth";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3import { whoami } from "https://esm.town/v/stevekrouse/whoami";
4
8 let handle = whoami().at(-1).slice(1).split(".")[0]
9 .replace("@", "");
10 return fetchJSON(
11 `https://pub-6feb98c078874338b9a3bce6ab56e815.r2.dev/${handle}/${key}`,
12 { agent: null },
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const untitled_B7XzWEHM = (
4 await fetch(
5 "https://api.val.town/v1/run/paulsun.parkingSpots" +
6 `?args=${JSON.stringify([lat, lng, radius])}`
1import { TEST_API } from "https://esm.town/v/stevekrouse/TEST_API";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function runAllTests2({ names }: { names: string[] }) {
5 return names.map((name) =>
6 fetchJSON(`${TEST_API}/eval/@stevekrouse.${name}()`)
7 .then(({ data, error }) => (data ?? error?.message) + ` (${name})`)
8 );
1import { fetch } from "https://esm.town/v/std/fetch";
2import process from "node:process";
3
4export let catFact = async (request: Request): Promise<Response> => {
5 let cat = await fetch("https://catfact.ninja/fact");
6 let { fact } = await cat.json();
7 const prompt =
8 "Rewrite this fact about cats as if it was written for 3 year old:\n\n" +
9 fact;
10 const story = await fetch("https://api.openai.com/v1/chat/completions", {
11 method: "POST",
12 body: JSON.stringify({
32 console.log(
33 length
34 ? `Successfully fetched ${length} row${length === 1 ? "" : "s"}`
35 : "No rows found",
36 );
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3export let aqi = async () => {
4 let pm25 = (
5 await fetchJSON(
6 "https://api.openaq.org/v2/latest?" +
7 new URLSearchParams({
14 const { LemmyHttp } = await import("npm:lemmy-js-client@0.18.1");
15 let client = new LemmyHttp(`https://${instance}`, {
16 fetchFunction: fetch,
17 });
18 const items =
1import { fetchRss } from "https://esm.town/v/pdebie/fetchRss";
2
3export function youtubeFeed(channelId: string, lastCheckDate?: string | number) {
4 return fetchRss(
5 "https://www.youtube.com/feeds/videos.xml?channel_id=" + channelId,
6 lastCheckDate,
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const proxyFetch2 = async (req, res) => {
4 const { url, options } = req.body;
5 try {
6 const response = await fetch(url, options);
7 return res.status(response.status).send(await response.text());
8 } catch (e) {
9 const errorMessage = e instanceof Error ? e.message : "Unknown error";
10 console.error("Failed to initiate fetch", e);
11 return res.status(500).send(`Failed to initiate fetch: ${errorMessage}`);
12 }
13};