Skip to content

Commit

Permalink
✨ add customizable api url promoApiUrl prop
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkjrs committed Aug 18, 2023
1 parent 2e908ee commit 4f531a2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/getToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
const url = 'https://promo.api.tincre.dev/token';
export async function getToken(
accessToken: string,
promoApiUrl?: string
): Promise<string> {
const url = promoApiUrl
? promoApiUrl + '/token'
: 'https://promo.api.tincre.dev/token';
let refreshToken: string;
// Example POST method implementation:
// Default options are marked with *
Expand All @@ -37,7 +44,6 @@ export async function getToken(accessToken: string): Promise<string> {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`,
// 'Content-Type': 'application/x-www-form-urlencoded',
},
});
console.debug(`getToken: awaiting response JSON`);
Expand Down

0 comments on commit 4f531a2

Please sign in to comment.