when i console.log(getUserData()) i get Promise {$$state: Object} but how can i retrieve actual value from this returned $$state object so the output be [someArray] or {someObject}..
getUserData = function(){
var defer = $q.defer();
$http.jsonp('http://api.zoopla.co.uk/api/v1/property_listings.js?area='+localData.area_name+'&api_key=xxx&jsonp=someCallback')
someCallback = function(userData){
//console.log(userData);
defer.resolve(userData)
}
return defer.promise;
};
console.log(getUserData())
That function returns promise. So you'll need to handle it properly. You expect async code to behave syncronously
More about angular deffered and promises: https://docs.angularjs.org/api/ng/service/$q