From 9b38d3661ec04a917da7ef4698f39f42939800b5 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Mon, 22 May 2023 22:41:48 -0400 Subject: [PATCH] refactor: make setting hostname and token in getSession more concise token in --- src/lib/session.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/lib/session.ts b/src/lib/session.ts index 7659864..fc6b0a3 100644 --- a/src/lib/session.ts +++ b/src/lib/session.ts @@ -13,12 +13,10 @@ export const getSession = async ( token?: string, hostname?: string ): Promise => { - if (!hostname) { - hostname = process.env.JMAP_HOSTNAME || API_HOSTNAME; - } - if (!token) { - token = process.env.JMAP_TOKEN; - } + hostname = hostname || process.env.JMAP_HOSTNAME || API_HOSTNAME; + + token = token || process.env.JMAP_TOKEN; + if (!token) { return Promise.reject( new Error( @@ -26,6 +24,7 @@ export const getSession = async ( ) ); } + const authUrl = `https://${hostname}/jmap/session`; const headers = { 'Content-Type': 'application/json',