Skip to content

Commit 56265a7

Browse files
SkyLeitepi0
authored andcommitted
fix: no token exception when tokenRequired is set to false (#118)
1 parent 77161b8 commit 56265a7

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

lib/auth/auth.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import getProp from 'dotprop'
22

33
import Storage from './storage'
4-
import { routeOption, isRelativeURL, isUnset, isSameURL } from './utilities'
4+
import { routeOption, isRelativeURL, isSet, isSameURL } from './utilities'
55

66
export default class Auth {
77
constructor (ctx, options) {
@@ -237,17 +237,13 @@ export default class Auth {
237237
requestWith (strategy, endpoint, defaults) {
238238
const token = this.getToken(strategy)
239239

240-
if (isUnset(token)) {
241-
return Promise.reject(new Error('No Token'))
242-
}
243-
244240
const _endpoint = Object.assign({}, defaults, endpoint)
245241

246242
if (!_endpoint.headers) {
247243
_endpoint.headers = {}
248244
}
249245

250-
if (!_endpoint.headers['Authorization']) {
246+
if (!_endpoint.headers['Authorization'] && isSet(token)) {
251247
_endpoint.headers['Authorization'] = token
252248
}
253249

0 commit comments

Comments
 (0)