I got this error after running the code below. Can anyone help?
TypeError: callback is not a function
api_call_arr.push(async function(callback) {
let api_result = await apiHelper.makeAPI('post', api_data);
if (api_result.Errors !== undefined) {
console.log('success 1');
} else {
console.log('error 1');
}
callback(null, true);
});
async.parallelLimit(api_call_arr, 5, function(err, data) {
console.log(err);
});
Using the async operator before your function turns it into a promise . I guess that the async lib is not handling this yet. You can remove the async keyword and do something like
apiHelper.makeAPI(...)
.then((result) => callback(null, result.Errors !== undefined))
.catch((err) => callback(err, false)))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.