UNPKG

knowmax-quest-utils

Version:

Utilities for creating a Knowmax Quest client.

36 lines 905 B
import { CONTENTTYPE_JSON } from "knowmax-quest-types"; export const headers = (initial) => { return new Headers(initial); }; class Headers { constructor(initial) { this.headers = { ...(initial ?? {}) }; } withBearer(token) { this.headers["Authorization"] = "Bearer " + token; return this; } withLanguage(language) { if (language) { this.headers["Accept-Language"] = language; } return this; } withContentTypeJson() { return this.withContentType(CONTENTTYPE_JSON); } withContentType(contentType) { this.headers["Content-Type"] = contentType; return this; } withHeader(key, value) { if (value) { this.headers[key] = value; } return this; } export() { return { ...this.headers }; } } //# sourceMappingURL=headers.js.map