1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { fetch } from "https://esm.town/v/std/fetch";
export async function valToString(val: string) {
if (val.startsWith("@")) {
val = val.slice(1);
}
const [author, name] = val.split(".");
const resp = await fetch(`https://api.val.town/v1/alias/${author}/${name}`);
if (resp.status !== 200) {
throw new Error(resp.statusText);
}
const { code } = await resp.json();
return code as string;
}
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!
October 23, 2023