File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,13 +44,18 @@ module.exports = function (APIWrapper) {
4444
4545 return authenticatedRequest ( options ) . catch ( err => {
4646 // Check for an expired token and request a new one
47- if ( err . response && err . response . headers [ 'www-authenticate' ] . indexOf ( 'invalid_token' ) !== - 1 ) {
47+ if ( err . response &&
48+ err . response . headers &&
49+ typeof err . response . headers [ 'www-authenticate' ] === 'string' &&
50+ err . response . headers [ 'www-authenticate' ] . indexOf ( 'invalid_token' ) !== - 1 ) {
4851 this . _log ( `The request failed due to an invalid bearer token. Requesting a new one...` )
4952
5053 return passport . refreshToken ( ) . then ( token => {
5154 return this . _processRequest ( this . originalRequestObject )
5255 } )
5356 }
57+
58+ return Promise . reject ( err )
5459 } )
5560 } )
5661 }
Original file line number Diff line number Diff line change @@ -164,8 +164,9 @@ describe('Terminators', function (done) {
164164
165165 // Set up the http intercepts - we ask it to return the same document we passed in
166166 // because that's what'll happen anyway
167+ delete documents [ 0 ] . _id
168+ delete documents [ 1 ] . _id
167169 var postScope = nock ( host ) . post ( post , documents ) . reply ( 200 , { results : [ fakeResponse . results ] } )
168-
169170 return wrapper
170171 . useVersion ( '1.0' )
171172 . useDatabase ( 'test' )
You can’t perform that action at this time.
0 commit comments