apefify不要在地图功能中推动项目
我有这个函数,该功能带有_.map函数,该功能循环每个元素或数组
一个比它可以在apefify存储中推出的项目,但数据集的元素永远是0。
为什么?
const Apify = require('apify')
const _ = require('underscore');
Apify.main(async () => {
let item = {}
let array = []
const dataset = await Apify.openDataset('dataset2', {forceCloud: true});
await mapping([1, 2, 3, 4, 5]);
function mapping(array){
_.map(array, async function (el) {
console.log("====")
console.log(el)
console.log("====")
await dataset.pushData(item) // <---- no items pushed
})
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正常地图功能不支持异步/等待。要么积聚成一个新数组,然后将其推入或用于(...的const ... of ...)循环
The normal map function doesn't support async/await. Either accumulate into a new array and push that or use for (const ... of ...) loop