Skip to content

Instantly share code, notes, and snippets.

@wKoza
Created August 10, 2017 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wKoza/a7c7d54b39e2eb530f210e00cd5fa543 to your computer and use it in GitHub Desktop.
Save wKoza/a7c7d54b39e2eb530f210e00cd5fa543 to your computer and use it in GitHub Desktop.
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