leo c leo c - 9 months ago 34
JSON Question

can't access nested JSON

When I try to display the object using console log, I am getting undefined. The line of code is:

var inform = data.Payload;
// If access allowed, set redirect location

The data is a JSON object with the following values:

"StatusCode": 200,
"Payload": "{\"sub\":\"1234567-1234-1234-1234-123456778\",\"token_use\":\"access\",\"scope\":\"aws.cognito.signin.user.admin\",\"iss\":\"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_99999999999\",\"exp\":1468310126,\"client_id\":\"xxxxxxxxxxxxx\",\"username\":\"usernam\"}"

I wanted to check the value of token_use.

var inform = JSON.parse(data.Payload);

You need to parson payload since its stringify