diff options
author | Markus Hatvan <markus_hatvan@aon.at> | 2021-09-14 19:58:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-14 19:58:52 +0200 |
commit | 95df3522a15631abc51a4295cae0ea401a8d4e1e (patch) | |
tree | e5eb0f368c947683f01458e912f21756fb0d99cb /src/api/utils | |
parent | docs: add sad270 as a contributor for bug, userTesting [skip ci] (#1941) (diff) | |
download | ferdium-app-95df3522a15631abc51a4295cae0ea401a8d4e1e.tar.gz ferdium-app-95df3522a15631abc51a4295cae0ea401a8d4e1e.tar.zst ferdium-app-95df3522a15631abc51a4295cae0ea401a8d4e1e.zip |
feat: add eslint-plugin-unicorn (#1936)
Diffstat (limited to 'src/api/utils')
-rw-r--r-- | src/api/utils/auth.js | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/api/utils/auth.js b/src/api/utils/auth.js index e493b2962..527c68840 100644 --- a/src/api/utils/auth.js +++ b/src/api/utils/auth.js | |||
@@ -1,7 +1,11 @@ | |||
1 | import localStorage from 'mobx-localstorage'; | 1 | import localStorage from 'mobx-localstorage'; |
2 | import { ferdiLocale, ferdiVersion } from '../../environment'; | 2 | import { ferdiLocale, ferdiVersion } from '../../environment'; |
3 | 3 | ||
4 | export const prepareAuthRequest = (options = { method: 'GET' }, auth = true) => { | 4 | export const prepareAuthRequest = ( |
5 | // eslint-disable-next-line unicorn/no-object-as-default-parameter | ||
6 | options = { method: 'GET' }, | ||
7 | auth = true, | ||
8 | ) => { | ||
5 | const request = Object.assign(options, { | 9 | const request = Object.assign(options, { |
6 | mode: 'cors', | 10 | mode: 'cors', |
7 | headers: { | 11 | headers: { |
@@ -16,12 +20,13 @@ export const prepareAuthRequest = (options = { method: 'GET' }, auth = true) => | |||
16 | }); | 20 | }); |
17 | 21 | ||
18 | if (auth) { | 22 | if (auth) { |
19 | request.headers.Authorization = `Bearer ${localStorage.getItem('authToken')}`; | 23 | request.headers.Authorization = `Bearer ${localStorage.getItem( |
24 | 'authToken', | ||
25 | )}`; | ||
20 | } | 26 | } |
21 | 27 | ||
22 | return request; | 28 | return request; |
23 | }; | 29 | }; |
24 | 30 | ||
25 | export const sendAuthRequest = (url, options, auth) => ( | 31 | export const sendAuthRequest = (url, options, auth) => |
26 | window.fetch(url, prepareAuthRequest(options, auth)) | 32 | window.fetch(url, prepareAuthRequest(options, auth)); |
27 | ); | ||