Мне нужно повторить запрос http после завершения предыдущего.Я использую обещание запроса наряду с async js.Мой фрагмент кода:
const _getAllProduct = (token, cb) => {
const _condition = () => last !== true;
const recordCount = 50;
let last = false;
let currentPage = 0;
console.log(`\n2. Getting All Products`);
let options = {
headers: {'Content-Type': 'application/json'},
json: true
};
let allProducts = [];
const _iterate = callback => {
options.url = `${domain.url}/all?page=${currentPage}&size=${recordCount}`;
console.log(`Options: ${JSON.stringify(options)}`);
console.log(`Here`);
rp(options)
.then(res => {
last = res.last;
allProducts = _.concat(allProducts, res.content);
currentPage++;
callback(null, true);
})
.catch(error => callback(error));
};
async.whilst(_condition, _iterate, error => {
if (error) return cb(error);
console.log(`Total %d records fetched from domain`, allProducts ? _.size(allProducts) : 0);
return cb(null, allProducts);
});
};
Проблема в том, что я получаю предупреждение в момент завершения запроса.Предупреждение - обещание создано, но не возвращено.В моей спецификации и требованиях используются async.js и модуль запроса-обещания .
(узел: 4159) Предупреждение: обещание было создано в обработчике в / home/xavient/Desktop/node/kwa/syncing/utils/product-synb-job.js:65:8 но не был возвращен из него, см. в новом обещании (/ home / xavient / Desktop / node / kwa / syncing / node_modules/bluebird/js/release/promise.js:79:10)