I am encountering an issue with the following code snippet:
var headers = new Headers();
// headers.append('Content-Type', 'application/json');
headers.append('Content-Type', 'application/x-www-form-urlencoded');
this.http.post(
'http://192.168.1.45:3000/testrestapi',
{headers: headers}
).map((res => res.json())
.subscribe(data => {
// we've got back the raw data, now generate the core schedule data
// and save the data for later reference
this.data = data;
console.log('Friends Provider was a success!');
console.log(JSON.stringify(data));
resolve(this.data);
},
(err)=>{
console.log('Error in Friends Provider!');
},
()=>{
console.log('Friends Provider network call has ended!');
}
)
)
});
While the code compiles successfully, my IDE is flagging some errors. I have included a screenshot of the errors for reference: https://i.sstatic.net/unT6c.png
I have been referencing the documentation available at https://angular.io/docs/js/latest/api/http/Http-class.html for guidance. However, I am using HTTP for POST requests and it is not as detailed as the examples for GET requests. I am uncertain about the correct type for the headers and the subscribe method. Any insights or suggestions would be greatly appreciated.