forked from p15670423/monkey
append options to existsing ones
This commit is contained in:
parent
6f827e5aa9
commit
38cf36e165
|
@ -40,7 +40,7 @@ export default class AuthService {
|
|||
})
|
||||
};
|
||||
|
||||
_authFetch = (url, options) => {
|
||||
_authFetch = (url, options = {}) => {
|
||||
const headers = {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
|
@ -50,10 +50,16 @@ export default class AuthService {
|
|||
headers['Authorization'] = 'JWT ' + this._getToken();
|
||||
}
|
||||
|
||||
return fetch(url, {
|
||||
headers,
|
||||
...options
|
||||
}).then(res => {
|
||||
if (options.hasOwnProperty('headers')) {
|
||||
for (let header in headers) {
|
||||
options['headers'][header] = headers[header];
|
||||
}
|
||||
} else {
|
||||
options['headers'] = headers;
|
||||
}
|
||||
|
||||
return fetch(url, options)
|
||||
.then(res => {
|
||||
if (res.status === 401) {
|
||||
this._removeToken();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue