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
幫助?