Thursday, 1 June 2017

How I can return the value of price object in the function?

function getPrice(productID){
  var price = {};
  let priceEndpoint = {
    uri: url + price_url.replace('{storeID}',store).replace('{productID}', productID),
    json: true // Automatically parses the JSON string in the response
  };
  rp(priceEndpoint)
    .then(function (result) {
    //Parse the Product Price
    parsePrice(price, result);
    console.log(price); //show the object
  })
  .catch();
  console.log(price); //show empty
} 

I want to return the object price, but it always returns an empty object.



via Costa

No comments:

Post a Comment