I want to pass directly Promise.all to a .then function like:
function returnPromise(a) {
return Promise.resolve(a);
}
function promiseList(arr) {
var list =[];
for(let i= 0; i < arr.length; i++) {
list.push(returnPromise(arr[i]))
}
return list;
}
var promsie = new Promise(function(fulfill, reject) {
fulfill(['a', 'b', 'c', 'd', 'e', 'f', 'g'])
});
promsie
.then(Promise.all)
.then(console.log)
But it outputs:
(node:19707) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Promise.all called on non-object
(node:19707) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.