1import { fetch } from "https://esm.town/v/std/fetch";
2import process from "node:process";
3
6 res: express.Response,
7) {
8 let response = await fetch("https://api.onepeloton.com/auth/login", {
9 method: "POST",
10 mode: "no-cors",
20 });
21 const session = await response.json();
22 let workoutResponse = await fetch(
23 `https://api.onepeloton.com/api/user/${session["user_id"]}/workouts`,
24 {
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3// Activity suggestions for when you're bored
4export let boredActivities = fetchJSON(
5 "https://www.boredapi.com/api/activity",
6);
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3// Currently broken! Val.Town cannot fetch from .gov sites
4// You can get these input values by calling https://api.weather.gov/points/{latitude},{longitude}
5export async function getWeatherGovData({ office, gridX, gridY }) {
6 const data = await fetchJSON(
7 `https://api.weather.gov/gridpoints/${office}/${gridX},${gridY}/forecast`
8 );
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let valTownApiExampleUser = (async () => {
4 const handle = "tmcw";
5 const response = await fetch(`https://api.val.town/v1/alias/${handle}`);
6 const json = await response.json();
7 return json;
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3// Cities named Brooklyn
4export let githubStarred = fetchJSON(
5 "https://api.github.com/users/stevekrouse/starred",
6);
1import { nowcastPMAqi } from "https://esm.town/v/stevekrouse/nowcastPMAqi";
2import { msHour } from "https://esm.town/v/stevekrouse/msHour";
3import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
4
5export async function openAqNowcastAQI({ location_id }) {
6 const { results } = await fetchJSON(
7 "https://api.openaq.org/v2/measurements?" +
8 new URLSearchParams({
1import { fetchABird } from "https://esm.town/v/crsven/fetchABird?v=1";
2
3export let exampleBird = fetchABird();
1import { parseHTML } from "https://esm.town/v/stevekrouse/parseHTML";
2import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
3
4// this function doesn't work yet, I'm still iterating on it
5export function fetchHTML(url: string, options?: any) {
6 return fetchText(url, options)
7 .then(parseHTML);
8}
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3// Public holidays in the US in 2023
4export let holidaysUS = fetchJSON(
5 "https://bed.paperee.repl.co/detail"
6);
1import { fetch } from "https://esm.town/v/std/fetch";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
3
4// Get the title of the top story on Hacker News
5export async function hnTopTenStories() {
6 const topStories: Number[] = await fetch(
7 "https://hacker-news.firebaseio.com/v0/beststories.json?print=pretty",
8 ).then((res) => res.json());
9 const top10Stories = await Promise.all(
10 topStories.slice(0, 10).map(async (id) => {
11 return await fetchJSON(
12 `https://hacker-news.firebaseio.com/v0/item/${id}.json`,
13 );