I'm trying to retrieve the response of a request using $resource
in AngularJS. Here is an example implementation:
angular.module('app').factory('AuthResource', ['$resource', function($resource) {
return {
isAuthenticated : function() {
return $resource('/api/v1/auth/authenticated').query();
}
}
}]);
When I call this service in my controller and use
console.log(AuthResource.isAuthenticated());
, instead of getting the expected result of {'success' : 'true'}
, I get a response with a Resource
object.
Resource {$resolved: false, $then: function, $get: function, $save: function, $query: function…}
$resolved: true
$then: function (callback, errback) {
success: false
__proto__: Resource
How can I access the actual returned object? I only need the data for routing purposes without applying it to any models. Any suggestions would be appreciated!
Thank you!