fix(utils): apiFetch should tolerate missing authentication

Signed-off-by: Katalina Okano <git@kat.cafe>
This commit is contained in:
41666 2020-12-21 05:04:12 -05:00
parent 6d8f40e30e
commit 91c27f6b9a

View file

@ -28,15 +28,12 @@ export const apiFetch = async <T>(
context?: NextPageContext
): Promise<T | null> => {
const sessionKey = getSessionKey(context);
if (!sessionKey) {
return null;
}
const authorizedInit: RequestInit = {
...(init || {}),
headers: {
...(init?.headers || {}),
authorization: `Bearer ${sessionKey}`,
authorization: sessionKey ? `Bearer ${sessionKey}` : '',
},
};