Promise unresolved

0

I have the following code:

getUserAccount : function(){
            var delay = $q.defer();
            $http.get(CommonUtilitiesService.getUrl()+'AllUserAccount')                     
            .then(function(response){
                if(response.status === 200){
                    if(response.data.message != '' && response.data.type=='warning'){
                        delay.reject(response.data.data);
                        swal({title: '',type: response.data.type,text: response.data.message});
                    }else{                                                          
                        delay.resolve(response.data.data);
                    }
                }
            })

            return delay.promise;

My problem is that when I run I get the following promise. How could I solve it?

    
asked by David pineda canales 08.06.2017 в 03:45
source

2 answers

0

I would solve it in the following way:

getUserAccount
  .then(function(data){
       // CODIGO_ACA
  })
  .catch(function(error){
  });

I leave you a functional example in plunker:

link

I hope it's what you're looking for, otherwise, do not hesitate to ask again.

    
answered by 08.06.2017 в 14:44
-1

You would have to solve it with .then(success, error) passing it as parameters two functions for Success or Error cases.

getUserAccount().then(function(response){
    console.log(response)
    //TU CODIGO
}, function(error){
    console.log(error)
    //TU CODIGO DE ERROR
});
    
answered by 08.06.2017 в 11:47