1import { fetch } from "https://esm.town/v/std/fetch";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export let hnTopStoryExecuted = (async () => {
5 const topStories: Number[] = await fetch(
6 "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty"
7 ).then((res) => res.json());
14 score: number;
15 by: string;
16 } = await fetchJSON(
17 `https://hacker-news.firebaseio.com/v0/item/${id}.json`
18 );
1import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
2let { valbeeTest } = await import("https://esm.town/v/stevekrouse/valbeeTest");
3
4export const valBeeExample = async () => {
5 return (valbeeTest = fetchText(
6 "http://numbersapi.com/random/math"
7 ));
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3// Returns NASA's Astronomy Picture of the Day (APOD)
4export const nasaAPOD = fetchJSON("cutt.ly/T7ksirK");
5// Forked from @iBrokeit.nasaAPOD
1import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=5";
2
3// Random math fact
4export let mathFact = fetchText(
5 "http://numbersapi.com/random/math"
6);
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3// Github profile
4export let githubUser = fetchJSON(
5 "https://api.github.com/users/hultner"
6);
15 (c) => c.text("current state is" + currentState),
16 );
17 return app.fetch(req);
18};
1import { fetch } from "https://esm.town/v/std/fetch";
2import { normalizeURL } from "https://esm.town/v/stevekrouse/normalizeURL?v=3";
3
4export const fetchJSON = async (url: string, options?: any) => {
5 let f = await fetch(normalizeURL(url), {
6 redirect: "follow",
7 ...options,
16 }
17 catch (e) {
18 throw new Error(`fetchJSON error: ${e.message} in ${url}\n\n"${t}"`);
19 }
20};
21// Forked from @stevekrouse.fetchJSON
1import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
2
3export let badArgs1 = (async () => {
4 // this should error helpfully
5 console.log(
6 await fetchText(
7 "https://api.val.town/v1/run/stevekrouse.id",
8 {
14 // this should error helpfully
15 console.log(
16 await fetchText(
17 "https://api.val.town/v1/run/stevekrouse.id",
18 {
26 // this is a proper call
27 console.log(
28 await fetchText(
29 "https://api.val.town/v1/run/stevekrouse.id",
30 {
1import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=5";
2
3// Random math fact
4export let mathFact = fetchText(
5 "http://numbersapi.com/random/math"
6);
1import { filterAlertsByLineAndStation } from "https://esm.town/v/roop/filterAlertsByLineAndStation";
2import { fetchAlerts } from "https://esm.town/v/roop/fetchAlerts";
3
4export async function currentCommuteAlertMessages() {
5 const alerts = (await fetchAlerts()).entity;
6 const filtered = filterAlertsByLineAndStation(alerts);
7 const messages = filtered.map((a) => ({