File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -236,7 +236,7 @@ class Client {
236236
237237 // Disallow non-object body if json enabled:
238238 if ( options . json && options . body && ( typeof options . body ) !== 'object' ) {
239- return Promise . reject ( new RequestError ( `Attempted to ${ method } with options.json==true, but body is a ${ typeof options . body } ` ) )
239+ throw new RequestError ( `Attempted to ${ method } with options.json==true, but body is a ${ typeof options . body } ` )
240240 }
241241
242242 const uri = this . _getFullUrl ( path )
@@ -252,7 +252,7 @@ class Client {
252252
253253 let cached = null
254254 if ( options . cache && ( cached = this . cache . get ( cacheKey ) ) ) {
255- return Promise . resolve ( cached )
255+ return cached
256256 } else {
257257 // Build request-specific options
258258 const requestOptions = {
@@ -328,11 +328,11 @@ class Client {
328328
329329 // Handle token expiration:
330330 if ( resp . status === 401 ) {
331- return Promise . reject ( new TokenExpirationError ( 'Detected token expiration fetching ' + options . uri ) )
331+ throw new TokenExpirationError ( 'Detected token expiration fetching ' + options . uri )
332332
333333 // Throw an error on error response?
334334 } else if ( ! resp . ok && options . throwForStatus ) {
335- return Promise . reject ( new ResponseError ( `Invalid response: for ${ options . uri } : "${ JSON . stringify ( options . body ) } "` ) )
335+ throw new ResponseError ( `Invalid response: for ${ options . uri } : "${ JSON . stringify ( options . body ) } "` )
336336
337337 // Ok response:
338338 } else {
Original file line number Diff line number Diff line change @@ -11,8 +11,6 @@ describe('Bib test', function () {
1111
1212 describe ( 'Bibs endpoint' , function ( ) {
1313 it ( 'should return a Bib' , async ( ) => {
14- console . log ( '(inside test) Stubbed fetch? ' , fetch , ! ! fetch . restore )
15-
1614 const resp = await client . get ( 'bibs/sierra-nypl/17746307' , { authenticate : true } )
1715 expect ( resp . data ) . to . be . a ( 'object' )
1816 expect ( resp . data ) . to . have . a . property ( 'id' , '17746307' )
You can’t perform that action at this time.
0 commit comments