I'am doing a jquery call to API website, which returns me the results in JSON format:
{
"results":[
{
"user":{
"gender":"female",
"name":{
"title":"mrs",
"first":"linda",
"last":"diaz"
},
"location":{
"street":"2333 oak lawn ave",
"city":"red bluff",
"state":"maryland",
"zip":"49309"
},
"email":"[email protected]",
"password":"blackman",
"md5_hash":"3c64b82d048c8754a30e292a1359fa39",
"sha1_hash":"d5095cf146dda75865d348f4ce4820b11b58b9fd",
"phone":"(880)-878-1658",
"cell":"(183)-179-1598",
"SSN":"425-55-1070",
"picture":"http:\/\/api.randomuser.me\/0.2\/portraits\/women\/8.jpg"
},
"seed":"2d589586d34c1c5",
"version":"0.2.1"
}
]
}
How can I access (or get values of) the items, for example: I want to console.log() the first name and the last name, get a phone number ?
Using a .(dot) not working for me, maybe i'am doing something wrong ? Here is a javascript code
$.ajax({
type: 'POST',
url: url + resultsQuery,
dataType: 'json',
success: function(data){
console.log(data);
}
});
console.log(data.results[0].user)but it returns me theundefinedconsole.log(data.results.length)