As I’m going through Mosh’s angular course I’ve been able to adjust up to this point with some of the outdated syntax. I’m running into an issue on Lesson 13 under “Consumming HTTP Services”, lecture Throwing application specific errors. The gist is I have a method that returns the output from a deleting a post.
and that allows him to adjust the method to
deletePost(id) {
console.log(id);
return this.http.delete(this.url + ‘/’ + id)
.catch( (error: Response) => {
// Stuff in here
);
}
That does not appear to work in angular 10. Can someone give me some direction? Do I need to switch to catchError? Does the newer version use .subscribe and then I can block out the error from there? I’m pretty fresh with this so I’m not sure what the right way forward is? Below is the full code to give a little context. Thank you for your help!
File post.service.ts
import { HttpClient } from ‘@angular/common/http’;
import { Injectable } from ‘@angular/core’;
import ‘rxjs/add/operator/catch’;
@Injectable({
providedIn: ‘root’
})
export class PostService {