1
2
3
4
5
6
7
8
9
import { Oura } from "https://deno.land/x/oura_api@0.5.7/mod.ts";
export const getSleepScore = async (ouraToken) => {
const oura = new Oura(ouraToken);
const today = new Date().toISOString().split("T")[0];
const yesterday = (d => (d.setDate(d.getDate() - 1), d))(new Date()).toISOString().split("T")[0];
const docs = await oura.getSleepDocuments(yesterday, today);
return docs.data.reverse()[0];
};
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!
v10
July 24, 2024