1
2
3
4
5
6
7
8
9
10
11
import { Oura } from "https://deno.land/x/oura_api@0.3.1/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];
console.log(yesterday);
const docs = await oura.getSleepDocuments(yesterday, today);
console.log(docs);
return docs.data.reverse()[0];
};
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.