api/queryAPI.js
/*
  validation for response['Error']
  incase resorce not found the error gets returned
  just miss-typing
  incase of new token it writes it to the file overwriting 
  the old one and change the value for the api property
  to repeat the request after 2 seconds
*/
validation for response['Error']
incase resorce not found the error gets returned
just miss-typing
incase of new token it writes it to the file overwriting
the old one and change the value for the api property
to repeat the request after 2 seconds
validation for response [ ' Error ' ] incase resorce not found the error gets returned just miss - typing incase of new token it writes it to the file overwriting the old one and change the value for the api property to repeat the request after 2 seconds
async function validResponse(response, caller, name) {
  if (response['Error']) {
    if (response['Error'] === 'Not authorized') {
      let newToken = await api.getToken().catch();
      let fileToken = {
        'token': newToken
      };
      let w = fs.createWriteStream('./token.json');
      w.write(JSON.stringify(fileToken));
      api.token = newToken;
      await sleep(2000).catch();
      return await caller(name);
    }
  } else {
    return true;
  }
}
async function validResponse ( response , caller , name ) { if ( response [ 'Error' ] ) { if ( response [ 'Error' ] === 'Not authorized' ) { let newToken = await api . getToken ( ) . catch ( ) ; let fileToken = { 'token' : newToken } ; let w = fs . createWriteStream ( './token.json' ) ; w . write ( JSON . stringify ( fileToken ) ) ; api . token = newToken ; await sleep ( 2000 ) . catch ( ) ; return await caller ( name ) ; } } else { return true ; } }
validation for response['Error']
incase resorce not found the error gets returned
just miss-typing
incase of new token it writes it to the file overwriting
the old one and change the value for the api property
to repeat the request after 2 seconds
validation for response [ ' Error ' ] incase resorce not found the error gets returned just miss - typing incase of new token it writes it to the file overwriting the old one and change the value for the api property to repeat the request after 2 seconds