Promise.mapSeries(idarrays, async function(id, callback) {
querydata.creative_id = '' + id;
debugasync("sync map debug : ", querydata);
const rs = await linktestbyid(querydata, queryday);
debugasync("debug async rs : ", rs);
return rs;
}).then((rs) => {
debug("all async rs : ", rs);
res.send(rs);
});
Promise写法对应的callback写法中的 async.mapSeries
async.mapSeries(idarrays, function(id, callback) {
querydata.creative_id = '' + id;
debugasync("sync map debug : ", querydata);
linktestbyid(querydata, queryday, (rs) => {
debugasync("debug async rs : ", rs);
callback(null, rs);
})
}, (err, rs) => {
debug("all async rs : ", rs);
res.send(rs);
});
注: const async = require('async');
var Promise = require('bluebird');
上述两个模块都需要安装哦!
原生Promise对象是没有Promise.mapSeries() 方法的!
bluebird 模块api:
https://itbilu.com/nodejs/npm/VJHw6ScNb.html