Public
Script
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
27
28
29
30
31
32
33
34
35
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export function val({ token, id }: {
token?: string;
id: string;
}): Promise<{
id: string;
author: {
id: string;
username: string;
};
name: string;
code: string;
public: boolean;
privacy: "public" | "private";
version: number;
runEndAt: string;
runStartAt: string;
logs: any[];
output: object;
error: object | null;
readme: string | null;
likeCount: number;
referenceCount: number;
}> {
const headers: RequestInit["headers"] = token
? {
Authorization: `Bearer ${token}`,
}
: {};
return fetchJSON(
"https://api.val.town/v1/vals/" + id,
{ headers },
);
}
October 23, 2023