Handle Unexpected errors
- Pass error function to subscribe method
ngOnInit() {
this.service.getPosts()
.subscribe(
data => {},
error => {
alert("An unexpected server occured")
console.log(error);
}
)
}
- Instead of the logging the error in console, we need to store the unexpected errors in the database on server