Friday 26 June 2020

getting api result value outside then function

Hi, I am new to nodejs and an facing an issue with request promise. I am running an API but I am not able to get the result of API out of then function.My code is as follows.var rp = require('request-promise'); var options = { uri: "URL", json: true }; rp(options) .then(function (body) { console.log(body); const data = body; }) .catch(function (err) { // API call failed... }); ## I want to print my api body here Thanks in advance

Submitted June 26, 2020 at 08:53PM by alpha2311

No comments:

Post a Comment