Good day, below I have
var request = require('request');
getFood = function(lst){
return new Promise(function(resolve, reject){
//console.log(lst)
request('https://api.jamesoff.net/recipe', function (error, response, recipe) {
lst.push(JSON.parse(recipe))
resolve(lst);
})
});
}
getFood([]).then(function(data){
for(var i = 0; i < 3; i++){
getFood(data)
}
return(data);
}).then(function(data){
console.log(data)
})
What I am aiming to accomplish is by using a promise chain place three recipies into an array using a loop. I only get one item and I know why this occurs, however I can't wrap my head around the procedure to accomplish my goal. Could I please get an explanation with code?