0

The data looks like this:

[
  {
    "passports": [
      {
        "identifier": "2238006043",
        "protocol": "oauth",
        "tokens": {
          "token": "2238006043-fACsU7gVtpZnkuerodfsfdsfsdfdffsfOck1R9Z",
          "tokenSecret": "BQN25aRkJcyES3yWFCa7sSpq212PKbB52Mplxpg58hICs"
        },
        "provider": "twitter",
        "user": "54e8bca1513ab1841ab6da01",
        "createdAt": "2015-02-21T17:13:05.371Z",
        "updatedAt": "2015-02-21T17:13:05.371Z",
        "id": "54e8bca1513ab1841ab6da02"
      }
    ],
    "username": "myUsername",
    "createdAt": "2015-02-21T17:13:05.362Z",
    "updatedAt": "2015-02-21T17:13:05.362Z",
    "id": "54e8bca1513ab1841ab6da01"
  },

And I'm trying to output something from passports like this:

console.log(util.inspect(res.passports[0].identifier, { showHidden: true, depth: null }));

res is the JSON object containing the data show below.

1
  • 1
    res[0].passports[0]... maybe Commented Feb 21, 2015 at 19:33

2 Answers 2

2

try

console.log(util.inspect(res[0].passports[0].identifier, { showHidden: true, depth: null }));

it looks like res is an array

Sign up to request clarification or add additional context in comments.

Comments

0

The res JSON objects contains a list of items. thats why its not giving any value. Please try this .

console.log(util.inspect(res[0].passports[0].identifier, { showHidden: true, depth: null }));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.