Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.