I downloading JSON data from an address by code:
return {
all: function () {
// var dfd = $q.defer();
var promise = $http.get("http://127.0.0.1:5000/mobile/").then(function (response) {
console.log(response.data.hits);
return response.data;
});
// Return the promise to the controller
return promise;
}
}
Console log returns array of Objects:
[Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object]
Any open of the object gives:
0: Object
$$hashKey: "object:20"
_id: "AVCZPOdoX5ZoBStgqx-J"
_index: "fb_events"
_score: 1
_source: Object
_type: "event"
__proto__: Object
As with the console log level I can get to the field _id?
Edit:
He wants to put the data into an array so as to have access to them through another loop which will return me an interesting record. Like:
get: function(chatId) {
for (var i = 0; i < chats.length; i++) {
if (chats[i].id === parseInt(chatId)) {
return chats[i];
}
}
return null;
}
_idfield like response.data.hits._id, but is does not work