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
27
import { BrowserContext } from "https://esm.town/v/pomdtr/browser";
import { valToListItem } from "https://esm.town/v/pomdtr/val_to_listitem";
export default async function(ctx: BrowserContext<{ user: string }>) {
const { user: userID } = ctx.params;
const resp = await fetch(`https://api.val.town/v1/me/likes?limit=100`, {
headers: {
Authorization: `Bearer ${Deno.env.get("valtown")}`,
},
});
if (!resp.ok) {
throw new Error(await resp.text());
}
const { data: vals } = await resp.json();
const items = vals.map(valToListItem);
return {
type: "push",
page: {
type: "list",
items,
},
};
}
// #web
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 2, 2024