From 4f531a21eb69f8bf13e2bf0657d12d0d3346d19a Mon Sep 17 00:00:00 2001 From: "Jason R. Stevens, CFA" Date: Fri, 18 Aug 2023 09:00:39 -0500 Subject: [PATCH] :sparkles: add customizable api url promoApiUrl prop --- src/getToken.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/getToken.tsx b/src/getToken.tsx index 3777fe8..7d31fb9 100644 --- a/src/getToken.tsx +++ b/src/getToken.tsx @@ -21,10 +21,17 @@ import fetch from 'cross-fetch'; * @param accessToken string JWT-encoded access token per * https://tincre.dev/docs/guides/how-to-auth. * + * @param promoApiUrl string | undefined base url for the Promo API, e.g. https://promo.api.tincre.dev. + * * @returns a usable refresh token you can store on the client. */ -export async function getToken(accessToken: string): Promise { - const url = 'https://promo.api.tincre.dev/token'; +export async function getToken( + accessToken: string, + promoApiUrl?: string +): Promise { + const url = promoApiUrl + ? promoApiUrl + '/token' + : 'https://promo.api.tincre.dev/token'; let refreshToken: string; // Example POST method implementation: // Default options are marked with * @@ -37,7 +44,6 @@ export async function getToken(accessToken: string): Promise { headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${accessToken}`, - // 'Content-Type': 'application/x-www-form-urlencoded', }, }); console.debug(`getToken: awaiting response JSON`);