Public
Cron
Forked from andreterron/fetchPelotonData
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { fetchPelotonWorkouts } from "https://esm.town/v/andreterron/fetchPelotonWorkouts";
import { email } from "https://esm.town/v/std/email?v=9";
import process from "node:process";
import { isSameDay } from "npm:date-fns";
export default async function checkTodayWorkout() {
const data = await fetchPelotonWorkouts(
"3f5bf759bb65494d8b35d26ec72b7340",
process.env.pelotonSessionId,
);
const latestWorkoutDate = new Date(data.data[0].created_at * 1000);
const didWorkOutToday = isSameDay(latestWorkoutDate, new Date());
if (didWorkOutToday) {
return;
}
email({
text: "You did not work out today",
subject: "It's time to sweat",
});
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
March 8, 2024