Skip to content

Commit

Permalink
feat: client - automatic time-zone header (#1674)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomfrew authored Nov 27, 2024
1 parent 7b9339f commit b5cbc27
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions node/templates/client/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export class Core {

const token = this.auth.accessToken.get();

let tz;
try {
tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
} catch {}

const result = await globalThis.fetch(
stripTrailingSlash(this.config.baseUrl) + "/json/" + action,
{
Expand All @@ -37,6 +42,7 @@ export class Core {
headers: {
accept: "application/json",
"content-type": "application/json",
...(tz ? { "time-zone": tz } : {}),
...this.config.headers,
...(token != null
? {
Expand Down Expand Up @@ -134,12 +140,12 @@ export class Core {
/**
* Get or set the access token from the configured token store.
*/
accessToken: this.config.accessTokenStore || new InMemoryStore(),
accessToken: this.config?.accessTokenStore || new InMemoryStore(),

/**
* Get or set the refresh token from the configured token store.
*/
refreshToken: this.config.refreshTokenStore || new InMemoryStore(),
refreshToken: this.config?.refreshTokenStore || new InMemoryStore(),

/**
* Returns data field set to the list of supported authentication providers and their SSO login URLs.
Expand Down

0 comments on commit b5cbc27

Please sign in to comment.