Skip to content

Commit

Permalink
✨(frontend) add jwt token into joanie generated api
Browse files Browse the repository at this point in the history
  • Loading branch information
rlecellier committed Feb 20, 2023
1 parent 54ee0d7 commit 989013e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/frontend/js/api/joanie/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import context from 'utils/context';
import { JOANIE_API_VERSION } from 'settings';
import { JOANIE_API_VERSION, RICHIE_USER_TOKEN } from 'settings';
import { ApiClientJoanie, OpenAPIConfig } from './gen';

/**
Expand All @@ -16,13 +16,14 @@ const getAPIEndpoint = () => {
return `${endpoint}/api/${version}`;
};

// TODO add auth with jwt
const config: OpenAPIConfig = {
BASE: getAPIEndpoint(),
VERSION: '1',
WITH_CREDENTIALS: true,
CREDENTIALS: 'include',
// TOKEN:
TOKEN: async () => {
return sessionStorage.getItem(RICHIE_USER_TOKEN) || '';
},
};

export const joanieApi = new ApiClientJoanie(config);
Expand Down

0 comments on commit 989013e

Please sign in to comment.