Search code examples
angularreduxnestjsngxs

How can I get the error from nestjs to angular with pipe()?


Show code

 this.authService
  .login(payload)
  .pipe(
    map((e: any) => e.token),
    tap(e => dispatch(new AuthLoginSuccess(e)))
  )
  .subscribe();

i am trying to show the error returning from nestjs backend to my angular frontend. The above function returns the token if the correct credentials are posted. I am not able to obtain the errors


Solution

  •   .login(payload)
      .pipe(
        map((e: any) => e.token),
        tap(e => dispatch(new AuthLoginSuccess(e))),
        catchError(error => { .... do stuff .... } )
      )
      .subscribe();
    

    This should allow you to grab any errors from your service.