1

I am trying to call a custom function in my error handling function but it won't work

my initial function looks like this:

register(model: LoginDto) {
  return this.http.post(this.baseURL + 'register', model).pipe(
    catchError(this.handleError)
  );
}

and my Error Handling function like this:

private handleError(error: any) {
console.log(error);
if (error != null && error instanceof HttpErrorResponse) {
  if (error.error != null) {
    const x = Object.keys(error.error).map(key => error.error[key]);
    const y = this.handleHttpError(x);
  }
}
return throwError(error);
}

in the Function handleHttpError i would check the error message but when i call it i get the error message TypeError: this.handleHttpError is not a function

what am i doing wrong ?

0

1 Answer 1

3

I think you need to pass the error,

 return this.http.post(this.baseURL + 'register', model).pipe((catchError(err => this.handleError(err)));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.