Back

Version 4

1/13/2024
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";

interface UpdateValArgs {
token: string;
code: string;
name?: string;
readme?: string;
privacy?: "public" | "unlisted" | "private"; // Added privacy option
}

export function updateVal({ token, code, name, readme, privacy }: UpdateValArgs): Promise<any> {
const body: Record<string, unknown> = {
code,
token,
name,
readme,
privacy,
};

return fetchJSON("https://api.val.town/v1/vals", {
headers: {
Authorization: `Bearer ${token}`,
},
method: "POST",
body: JSON.stringify(body),
});
}
Updated: January 13, 2024