I am trying to write a code as follows -
var rp = require('request-promise');
var myArr = [0,1,2,3,4,5];
var a = 0;
for( var i in myArr) {
rp('someURL?q='+myArr[i])
.then(function (response) {
myArr[i] = response;
});
}
return myArr;
How can I wait for each request then proceed the for loop for next iteration and in the end return myArr?