I have a recursive function like so
function missingItemsPromise() {
return new Promise(resolve => {
if (missingItems == 0) {
con
you are missing the return statement inside the else condition
function missingItemsPromise() {
return new Promise(resolve => {
if (missingItems == 0) {
console.log('resolves');
console.log(products);
return resolve();
} else {
page++;
url = getUrl(id, page);
http.get(url, function(xres) {
xres.setEncoding('utf8');
xres.on('data', function (xtraBody) {
console.log('calling');
var xtraJson = JSON.parse(xtraBody);
var xtraProducts = xtraJson['products'];
products = products.concat(xtraProducts);
productsLength = products.length;
missingItems = total - productsLength;
return missingItemsPromise(); //this is the line that changes
});
});
}
});
};