Return data from http inside function

后端 未结 1 1126
小蘑菇
小蘑菇 2021-01-20 18:27

I\'m using this and this reference, to return data from an http-request inside a function:

function getdetails(id) {

            var datafordetails = {
             


        
相关标签:
1条回答
  • 2021-01-20 19:07

    The output you are getting is nothing but a promise object which has been returned by the $http.get method. Basically you need to put .then function over getdetails2 function for getting data from the promise object when it resolve/reject.

    Code

    getdetails2('12345').then(function(data){ //success callback
       //you will get data here in data parameter of function,
       var testing = data;
    }, function(error){ //error callback
       console.log(error)
    })
    
    0 讨论(0)
提交回复
热议问题