TypeError: expecting an array or an iterable object but got [object Null]
adoyle-h opened this issue · 3 comments
Please answer the questions the best you can:
-
What version of bluebird is the issue happening on? 3.7.2
-
What platform and version? (For example Node.js 0.12 or Google Chrome 32) NodeJS v12.13.1
-
Did this issue happen with earlier version of bluebird? I am not sure.
(Write description of your issue here, stack traces from errors and code that reproduces the issue are helpful)
An error TypeError: expecting an array or an iterable object but got [object Null]
is thrown by below code.
'use strict';
const Promise = require('bluebird');
const doSomething = () => {};
async function main() {
await Promise.map({}, doSomething);
}
main().catch((err) => {
console.error(err.stack);
});
I think Promise.map
should not throw error and doSomething
function is not invoked when the iterable input is an empty object.
Sorry, its my fault.
@jsponz Because the first argument only accepts Iterable object. The array is iterable, but the {}
is not.
Read the documents. http://bluebirdjs.com/docs/api/promise.map.html
You should use Promise.props
and other apis.