This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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