1import { fetchJSON } from "https://esm.town/v/mgruel/fetchJSON";
2
3type UserParams = {
49 headers.Authorization = `Bearer ${params.token}`;
50 }
51 return fetchJSON<Result<P>>(url, { headers });
52}
1import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=5";
2
3// Edit Discord message via webhook
8}) => {
9 const url = `${webhookUrl}/messages/${messageId}`;
10 const text = await fetchText(url, {
11 method: "PATCH",
12 headers: {
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3// GitHub followers
4export let githubFollowers = fetchJSON(
5 "https://api.github.com/users/stevekrouse/followers",
6);
1import { fetchNotion } from "https://esm.town/v/andreterron/fetchNotion";
2
3export let notionSearch = async ({token, query}) => {
4 const response = await fetchNotion({token, method: "POST", path: "v1/search", body: {page_size: 100, query}})
5 return response.results
6}
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const proxyFetch = 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 }
9 catch (e) {
10 const errorMessage = e instanceof Error ? e.message : "Unknown error";
11 console.error("Failed to initiate fetch", e);
12 return res.status(500).send(`Failed to initiate fetch: ${errorMessage}`);
13 }
14};
15// Forked from @alp.proxyFetch
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let canvasText = (async (req: Request) => {
8 const canvas = createCanvas(1200, 675);
9 const ctx = canvas.getContext("2d");
10 const boldFontRes = await fetch(
11 `https://websharebox.s3.amazonaws.com/SpaceGrotesk-Bold.ttf`,
12 );
16 weight: "bold",
17 });
18 const normalFontRes = await fetch(
19 `https://websharebox.s3.amazonaws.com/SpaceGrotesk-Medium.ttf`,
20 );
118 ctx.fill();
119 // image
120 const { fetchRemote } = await import(
121 "https://deno.land/x/fetchbase64@1.0.0/mod.ts"
122 );
123 const imgBase64 = await fetchRemote(query.get("img"));
124 ctx.imageSmoothingEnabled = false;
125 const img = await loadImage(imgBase64);
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function csp(url) {
4 const response = await fetch(url);
5 const policies = response.headers.get("Content-Security-Policy").split(";")
6 .map((p) => p.trim()).filter(String);
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function spellCheck(req: express.Request, res: express.Response) {
4 let response = await fetch("https://www.dnd5eapi.co/api/spells");
5 let data = await response.json();
6 let countOfSpells = data["count"];
7 let randomSpellNumber = Math.floor(Math.random() * countOfSpells);
8 let randomSpell = data["results"][randomSpellNumber];
9 let response2 = await fetch(
10 `https://www.dnd5eapi.co/api/spells/${randomSpell["index"]}`,
11 );
4import { refreshData } from "https://esm.town/v/u/refreshData";
5
6export async function refresher_fetcher() {
7 for (const [name, time] of Object.entries(
8 refreshData as Record<string, number>
1import { msDay } from "https://esm.town/v/stevekrouse/msDay?v=1";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
3
4export let openAQLocation = async ({
12 return q.charAt();
13 // Test
14 const { results } = fetchJSON(
15 "https://api.openaq.org/v2/locations?" +
16 new URLSearchParams({