I have a service that returns a promise. I would like to check if the return value is empty. How can i achieve this. I think I need to somehow extract the return value from the promise object.
Here is my resource:
app.factory('Auth', ['$resource',
function($resource) {
return $resource('/user/identify', {}, {
identify: {
url: '/user/identify'
},
});
}
]);
Then in the service:
Auth.identify(function(data) {
if (!_.isEmpty(data)) {
}
});
The console data log gives:
Resource
$promise: Object
$resolved: true
__proto__: Resource
I can check the expected properties when the object is not empty, but would like to use a more general method.
source
share