1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { paths } from "https://esm.town/v/pomdtr/openapi_schema";
import createClient2 from "npm:openapi-fetch";
/**
* Create a Valtown API client
* @param options - Valtown API client options
* @param options.baseUrl - API base URL
* @param options.token - API token (if null, no token will be used, if undefined, the token from the environment variable "valtown" will be used)
*/
export default function createClient(options: {
baseUrl?: string;
token?: string | null | undefined;
} = {}) {
return createClient2<paths>({
baseUrl: options?.baseUrl ?? "https://api.val.town",
headers: options?.token === null ? {} : { Authorization: `Bearer ${options.token ?? Deno.env.get("valtown")}` },
});
}
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!
May 3, 2024