I need to make many API calls with different settings, so I'm trying to write a function that will take a settings object and return text. I had this working before function-izing it, but now I can't figure out how to get the data out. The data
variable is good here, but how can I pass it back to answer
? I tried adding a this
reference, this is my current attempt.
function REST(settings) {
var whatIneed;
var parent = this;
client.request(settings).then(
function(data) {
console.log(data);
parent.whatIneed = data;
},
function(response) { PromiseError(response); } )
console.log(whatIneed);
return whatIneed;
}
answer = REST(settings);