Move auth token logic to useApi hook.
This commit is contained in:
1 parent
d19b6b5a82
commit
3a8bfd1dbd
7 files changed
+56
-28
No files matched your search
@@ -1,9 +1,6 @@
|
||||
import { makeUrl } from './url';
|
||||
import { AUTH_TOKEN } from './constants';
|
||||
|
||||
export const apiRequest = (method, url, body, headers) => {
|
||||
const authToken = getItem(AUTH_TOKEN);
|
||||
|
||||
return fetch(url, {
|
||||
method,
|
||||
cache: 'no-cache',
|
||||
@@ -11,7 +8,6 @@ export const apiRequest = (method, url, body, headers) => {
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
...(authToken ? { Authorization: `Bearer ${authToken}` } : {}),
|
||||
...headers,
|
||||
},
|
||||
body,
|
||||
|
||||
Reference in new issue
Block a user