How to get a specific value from the json output in ionic

After subscribing to a post i got the output response as
token'xxxxxxxxxxxx',{headers: headers})
            .subscribe(newToken => {

Here I want to read the value of access_token and store it in a variable. I don’t know how to read it, can someone help me?

Try this. If it doesn’t work please paste your JSON response in the post and I’ll check again'xxxxxxxxxxxx',{headers: headers})
            .subscribe(res => {
              let newToken = res.body[access_token]
              console.log(newToken) //stored in newToken variable

It is saying as Property 'body' does not exist on type 'Response'. I’m trying it in the emulator how can I copy it(output)?

ionic cordova emulate ios -l -c
ionic cordova emulate android -l -c
Then console.log your response instead of alert. The response will log to the terminal

when I try that I’m getting error as

[ERROR] Multiple network interfaces detected!

        You must select an external-facing IP for the dev server that your device or emulator has access to with the --address option.

so it’s some thing like this{"_body":{\"access_token\":\"AQVbjkhkjdf987fidfiu97t895uifhhfkjhgfkjdhgkjhgifugyy8f789gfiugifvhv8yy9yuhvchvjhjkhfdhkjhdf878789ufduidfidufygy89fiudufyi\",\"expires_in\":5183999}",
I’ve typed it by seeing it.


let newToken = res.body.access_token

getting the error as Property 'body' does not exist on type 'Response'.

add _body

let newToken = res._body.access_token

I’ve tried it but I’m getting the same output response that I’ve in the question.

body = newToken._body;
token = body.access_token