Instantly share code, notes, and snippets.

@wKoza /handling.ts Secret
Created Aug 10, 2017

Embed
What would you like to do?
this.http.get<Article>('api.learn-angular.fr/articles/12').subscribe(
data => {
console.log("Titre: " + data.title);
},
(err: HttpErrorResponse) => {
if (err.error instanceof Error) {
// A client-side or network error occurred. Handle it accordingly.
console.log('An error occurred:', err.error.message);
} else {
// The backend returned an unsuccessful response code.
// The response body may contain clues as to what went wrong,
console.log(`Backend returned code ${err.status}, body was: ${err.error}`);
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment