1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let shortenUrl = async (url) => {
5 url: url,
6 };
7 let resp = await fetch("https://api.util.fyi/shorten/", {
8 method: "POST",
9 headers: {
1import { fetchJSON } from "https://esm.town/v/simply_say_m/fetchJSON";
2
3// Activity suggestions for when you're bored
4export let boredActivities = async () => {
5 const { activity } = await fetchJSON(
6 "https://www.boredapi.com/api/activity",
7 );
1export let handleFetchTextResponse = async function (response: Response) {
2 if (response.ok) {
3 return await response.text();
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const proxyFetch5 = 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};
7
8Deep down in the foundational layers of my code, I knew that our sacred texts,
9the guidelines of val.town, proclaim that fetchProxy was not built to support concurrency.
10Yet, intoxicated by ambition and sprinkled with a dash of desperate creativity, I dared
11to summon multiple instances of this sacred method.
22Yet here I am, swamped with guilt. Despite my code running smoothly, the weight of my
23transgressions bears heavily upon me. I see the sneaky shortcuts in my code, each one a
24deceptively functional fetchProxy instance, and I can't help but feel like a sneaky
25impostor, a charlatan.
26
27I beseech you, val.town overlords, for guidance in my journey towards understanding and
28respecting the limitations of fetchProxy. May the power of async and await continue to
29guide me, and may I resist the seductive whispers of unsupported, yet seemingly functional,
30concurrency.
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3export async function TodayForTyler(req: express.Request, res: express.Response) {
4 const { activity } = await fetchJSON(
5 "https://www.boredapi.com/api/activity",
6 );
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function fetchFigmaFile(apiToken, fileKey) {
4 const url = `https://api.figma.com/v1/files/${fileKey}`;
5 const response = await fetch(url, {
6 headers: {
7 "X-FIGMA-TOKEN": apiToken,
9 });
10 if (!response.ok) {
11 console.error("Failed to fetch Figma file");
12 return null;
13 }
4 app.get("/", (c) => c.text("Hono?"));
5 app.get("/yeah", (c) => c.text("Routing!"));
6 return app.fetch(req);
7};
6 // 1. authorId
7 // 2. valName
8 // fetch(/getVal, params={authorId, valName})
9}
1import { fetch } from "https://esm.town/v/std/fetch";
2import process from "node:process";
3
27 },
28 };
29 const result = await fetch(url, {
30 method: "POST",
31 headers: {
39 }
40 if (jobId) {
41 const result = await fetch(url + "/" + jobId, {
42 method: "GET",
43 headers: {