mercredi 5 juillet 2017

Karama returning .seach is not a function

I am running my Angular 4 project through its test and I am getting an error on a component being created. The error is located to a service which is checking if a JWT is expired.

Failed: errorMsg.search is not a function

The code is originating out of an error handler method (which checks for jwt expired in the body being returned from REST API calls).

private handleError(err) {
  const errorMsg: String = err._body;
  const isExpired = errorMsg.search('jwt expired');
  if (isExpired > 0) {
    // write out to toast
  } else {
    // log error
  }
}

I have declared the errorMsg as a String in the hope it would suppress error. but I am not getting anywhere.

Any thoughts?

Aucun commentaire:

Enregistrer un commentaire