0

I get a json data from the api and when i render the data only inside the then function i get the normal JSON when it comes out of the scope it again become promise.

 getproducts: function () {
var xx ={};
var apidata = Vue.axios.post('http://127.0.0.1:5000/').then((response) => {
                        return response.data
                        }).then(function(result) {
        //  console.log(result.products) //will log results.
          console.log(result.products);
            return result.products;

                    })
console.log(apidata)
return apidata
 }`

the result.products gives normal json data but when i return the apidata it became promise.

Alvin John Babu
  • 1,710
  • 2
  • 16
  • 26
  • 1
    `console.log(apidata)` get executed even before the promise is resolved . Check this https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call – brk Oct 26 '18 at 16:45
  • thats not what i need?? i am using vue js computed property to render the json data and i am stuck on it – Alvin John Babu Oct 26 '18 at 17:22

0 Answers0