So I followed the error handling guide in the angular docs. I always seem to receive the error in my service, however, my console always displays my error object as '[object Object]'. Does anyone know what causes this and how I can fix this?
My service file
subViewPlus(section, sign){
return this.http.get('http://localhost:3000/forum/subViewPlus/' + section + '/' + sign)
.pipe(catchError(this.handleError)
}
private handleError(error: HttpErrorResponse) {
if (error.error instanceof ErrorEvent) {
// A client-side or network error occurred. Handle it accordingly.
console.error('An error occurred:', error.error.message);
} else {
// The backend returned an unsuccessful response code.
// The response body may contain clues as to what went wrong,
console.error(
`Backend returned code ${error.status}, ` +
`body was: ${error.error}`);
}
// return an ErrorObservable with a user-facing error message
return new ErrorObservable(
'Something bad happened; please try again later.');
};
Screenshot that shows the logs to the console: how do I transform this [body body] into something more useful?
