Mikyas TADESSE Mikyas TADESSE - 8 months ago 59
AngularJS Question

How to access data in a promise angularjs

I wanted to access a data in promise. I have the following code :

function getUser() {
Users.query({username: usersOnline}).$promise.then(function (results) {
$scope.userss = results;
return results;
}, function(error) {
// console.log(error);
//$scope.meetups = [];

But i get an error saying cant find property then of undefined can you help

Answer Source

Return Users.query promise from getUser user function, as caller function is performing .then(expecting promise) there.

function getUser() {
//return promise here
    return Users.query({username: usersOnline}).$promise
    //other code as is