@@ -41,7 +41,7 @@ export class ApiInstance {
4141 | Record < string , any >
4242 | Promise < Record < string , any > > = ( ) => ( { } )
4343
44- private waiting = false
44+ private disabled = false
4545 // "<method>:<path>": [() => void, ...]
4646 private waitingQueues : Map < string , ( ( ) => Promise < unknown > ) [ ] > = new Map ( )
4747 constructor (
@@ -219,6 +219,7 @@ export class ApiInstance {
219219 body ?: RequestInit [ 'body' ]
220220 }
221221 ) {
222+ if ( this . disabled ) return ApiInstance . createEmptyRes < ResponseDataType > ( 0 )
222223 // this.addToQueue(`${this.genKey('GET', path)}`, () => {})
223224 const res = await this . send < ResponseDataType > ( path , options )
224225 const headers = await this . headerGetter ( )
@@ -458,7 +459,7 @@ export class ApiInstance {
458459 . replace ( ' ' , '-' )
459460 ] = value
460461 } )
461- this . waiting = false
462+ this . disabled = false
462463 Object . entries ( headers || { } ) . map ( ( [ key , value ] ) => {
463464 // uppercase the dash separated tokens
464465 formattedHeaders [
@@ -518,6 +519,9 @@ export class ApiInstance {
518519 headers : Record < string , string >
519520 } & RequestInit
520521 }
522+ enabled ( status : boolean = true ) {
523+ this . disabled = ! status
524+ }
521525 private static createEmptyRes < ResponseDataType = any > ( status : number = 408 ) {
522526 return {
523527 status,
0 commit comments