Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { fetch } from "https://esm.town/v/std/fetch";
import process from "node:process";
export async function setSFTidbytImage({ image, key }: {
image: string;
key: string;
}) {
const apiKey = process.env.sf_tidbyt_api_key;
const deviceId = process.env.sf_tidbyt_device_id;
const res = await fetch(
`https://api.tidbyt.com/v0/devices/${deviceId}/push`,
{
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
},
body: JSON.stringify({
"deviceID": deviceId,
"image": image,
"installationID": key,
"background": false,
}),
},
);
return { status: res.status, body: await res.json() };
}
December 18, 2023