javascript - How can I access json data inside array? -


i need json value. data -

[      {         "statuscode":200,       "body":{            "token":"xxxxx"       },       "headers":{            "date":"thu, 28 jul 2016 11:03:17 gmt",          "server":"apache/2.2.15 (centos)",          "x-powered-by":"php/5.6.22",          "cache-control":"private, must-revalidate",          "etag":"\"9517ef72d528ad7a3bc04c64d1cc1cc9\"",          "set-cookie":[               "xsrf-token=xxx; expires=thu, 28-jul-2016 13:03:17 gmt; max-age=7200; path=/",             "laravel_session=eyjpdii6ikzitxdytgtpzlrkc1hmqkptuwpzsee9psisinzhbhvlijoicgxlumjxrzlcl2dgttdvcvjiq1g2qth4enqxddi5nelcbgjkvllkyvr0mg1lqtljafhhufjsuvvxtytheuxqajzjv3fvukh2suhpk0ztelhiqjcxvk5npt0ilcjtywmioijkotg1mwfiyjy5ztdhnthkodk5n2y1mmrlowewzwmwywq4mge4zdvjmwrjmgmwnja0mtlmnjq1yznmndm3nwvkin0%3d; expires=thu, 28-jul-2016 13:03:17 gmt; max-age=7200; path=/; httponly"          ],          "vary":"accept-encoding",          "content-length":"305",          "connection":"close",          "content-type":"application/json"       },       "request":{            "uri":{               "protocol":"http:",             "slashes":true,             "auth":null,             "host":"api.shobkichhu.com",             "port":80,             "hostname":"api.shobkichhu.com",             "hash":null,             "search":null,             "query":null,             "pathname":"/api/auth/login",             "path":"/api/auth/login",             "href":"http://api.shobkichhu.com/api/auth/login"          },          "method":"post",          "headers":{               "content-type":"application/json",             "accept":"application/json",             "content-length":45          }       }    },    {         "token":"xxxx"    } ] 

i need access token. how can access token ?

thanks in advance

this solution

var data =[      {         "statuscode":200,       "body":{            "token":"xxxxx"       },      },    {         "token":"xxxx"    } ];   console.log(data[0].body.token); // first token console.log(data[1].token); // second token 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -