I'm looking to make a post request that sends some information such as the first name, last name, email, mobile number, and salary in Angular. However since the ".subscribe" method has been deprecated i'm unable to use it. How can I change this so that it works?
postEmployeeDetails(){
this.employeeModelObj.firstName = this.formValue.value.firstName;
this.employeeModelObj.lastName = this.formValue.value.lastName;
this.employeeModelObj.email = this.formValue.value.email;
this.employeeModelObj.mobile = this.formValue.value.mobile;
this.employeeModelObj.country = this.formValue.value.country;
this.api.postUser(this.employeeModelObj)
.subscribe(res=>{
console.log(res);
alert('User added successfully')
},
err=>{
alert("something went wrong")
})
This is my PostUser post request:
export class ApiService {
constructor(private http : HttpClient) { }
postUser(data : any) {
return this.http.post<any>("http://localhost:3000/posts", data)
.pipe(map((res:any)=>{
return res;
}))
}