@@ -380,27 +380,30 @@ var DgraphClientStub = (function () {
380380 } ;
381381 DgraphClientStub . prototype . callAPI = function ( path , config ) {
382382 return __awaiter ( this , void 0 , void 0 , function ( ) {
383- var url ;
383+ var url , response , json , errors ;
384384 return __generator ( this , function ( _a ) {
385- url = this . getURL ( path ) ;
386- if ( this . accessToken !== undefined && path !== "login" ) {
387- config . headers = config . headers !== undefined ? config . headers : { } ;
388- config . headers [ "X-Dgraph-AccessToken" ] = this . accessToken ;
389- }
390- return [ 2 , fetch ( url , config )
391- . then ( function ( response ) {
385+ switch ( _a . label ) {
386+ case 0 :
387+ url = this . getURL ( path ) ;
388+ if ( this . accessToken !== undefined && path !== "login" ) {
389+ config . headers = config . headers !== undefined ? config . headers : { } ;
390+ config . headers [ "X-Dgraph-AccessToken" ] = this . accessToken ;
391+ }
392+ return [ 4 , fetch ( url , config ) ] ;
393+ case 1 :
394+ response = _a . sent ( ) ;
392395 if ( response . status >= 300 || response . status < 200 ) {
393396 throw new Error ( "Invalid status code = " + response . status ) ;
394397 }
395- return response . json ( ) ;
396- } )
397- . then ( function ( json ) {
398- var errors = json . errors ;
398+ return [ 4 , response . json ( ) ] ;
399+ case 2 :
400+ json = _a . sent ( ) ;
401+ errors = json . errors ;
399402 if ( errors !== undefined ) {
400403 throw new errors_1 . APIError ( url , errors ) ;
401404 }
402- return json ;
403- } ) ] ;
405+ return [ 2 , json ] ;
406+ }
404407 } ) ;
405408 } ) ;
406409 } ;
0 commit comments