0
我有这样的代码:减法'数组累加器中不能使用推式方法吗?
let fullConversations = conversationIdsByUser.reduce(async function(acc, conversation) {
const message = await MessageModel.find({ 'conversationId':conversation._id })
.sort('-createdAt')
.limit(1); // it returns an array containing the message object so I just get it by message[0]
return acc.push(message[0]);
},[]);
这里我的累加器是一个数组,消息[0]是,我要推的对象。但我有这个错误:
(node:516) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: acc.push is not a function
帮助?