To retrieve a property of an Object that originated from an HTTP Post in Angular, you can use the dot notation to access the particular property.
For example, if you have a response object named 'data' that contains a property named 'name', you can retrieve its value like this:
this.http.post(url, postData).subscribe((data: any) => {
const name = data.name;
console.log(name);
});
Alternatively, you can also use the bracket notation to access the property:
this.http.post(url, postData).subscribe((data: any) => {
const name = data['name'];
console.log(name);
});
In either case, you need to make sure that the property name and case match exactly with the one returned from the HTTP Post API.
Asked: 2023-07-08 00:22:03 +0000
Seen: 10 times
Last updated: Jul 08 '23