I have this object, and I want to access his properties. If I print the object I get the following outpout:
console.log(Poller)
Object {data: Object}
data: Object
response: Object
clients_id: Array[4]
customers: Array[4]
error: false
notify: Array[4]
__proto__: Object
__proto__: Object
__proto__: Object
but if I run:
console.log(Poller.data)
app.js:177 Object {} // -> empty object
If I run
console.log(Poller.data.response)
undefined
How can I access the clients_id | customers | notify details?
P.S The object is made with this AngularJS service:
factory('Poller', ["$http", "$timeout", "store", "URL", function($http, $timeout, store, URL){
var notification = {};
var data = {
"hairdresser_id": store.get("userId")
}
var poller = function(){
$http.post(URL.url + 'check_for_notifications', data).then(function(res){
if (res.data.error){
console.log(res.data.error);
} else {
notification.response = res.data;
console.log(res.data.notify);
}
$timeout(poller, 5000);
});
}
poller();
return {
data: notification
};
}]);