I have encountered an issue with a function I wrote for sending an http put request to update data. The function is not receiving any data:
updateHuman(human: Human) {
const url = `${this.url}/${human.id}`;
const data = JSON.stringify(human);
return this.http.put(url, data).map(
response => response.json().data as Human,
error => console.log(error)
);
}
However, when I made some changes to the function as shown below, it started working without any issues:
updateHuman(human: Human) {
const url = `${this.url}/${human.id}`;
const data = JSON.stringify(human);
return this.http.put(url, data).map(() => human);
}
I am curious to know why the first version of the function did not work while the second one works perfectly. Can anyone provide an explanation?