Sorry if this is obvious but I just cant seem to get my head around it and I cannot think of the right way to phrase my google query (even though I have been trying).
I have the following JSON
which is returned from a web API.
{"firstName":"Joe","surname":"bloggs","email":"joe.bloggs@gmail.com"}
I want to access the email from the JSON
in my angular app and I getting the data with the followig:
this.auth.getUserDetails(username, password).subscribe(data => {
console.log(data)
})
data.email
doesnt work,
data[2].value
doesnt work
How do I specifically reference the email
from the data
object?
Update
I have just checked the network response to the Web API call and it returns this:
"{\"firstName\":\"Joe\",\"surname\":\"bloggs\",\"email\":\"joe.bloggs@gmail.com\"}"
but just to confirm if I print data to the console I get the first line above.
Update2
Code from getUserDetails:
getUserDetails(username, password){
let params = new HttpParams({ fromString: 'username=' + username + '&password=' + [password] });
return this.httpclient.get(this.myUrl, { params });
}