error en el wallet.service.ts no esta leyendo bien los datos de el endpoint all #3
Description
[Nest] 33420 - 31/05/2024, 17:56:18 LOG [NestApplication] Nest application successfully started +7ms
It is highly recommended to use a minimum Redis version of 6.2.0
Current: 5.0.14.1
[Nest] 33420 - 31/05/2024, 17:56:21 ERROR [ExceptionsHandler] Cannot read properties of undefined (reading 'balance')
TypeError: Cannot read properties of undefined (reading 'balance')
POSTMAN
{
"statusCode": 500,
"message": "Internal server error"
}
ERROR VIENE DE LA FORMA EN QUE SE ACCEDE A LOS DATOS EN getwallets da a undefine
async getWallets(email: string) {
const data = await this.userModel.aggregate([
{ $match: { email } },
{ $unwind: '$wallets' },
{ $project: { _id: 0, wallets: 1 } },
{
$lookup: {
from: "wallets",
localField: "wallets",
foreignField: "_id",
"pipeline": [
{ "$project": { transactions: 0 } }
],
as: "walletsData"
}
}
]).exec();
if (data && data.length > 0) {
return data.map(wallet => {
return {
balance: wallet.walletsData[0].balance,
address: wallet.walletsData[0].address,
coin: wallet.walletsData[0].coin,
chainId: wallet.walletsData[0].chainId,
walletId: wallet.walletsData[0]._id
}
})
}
}
aun en busca de una solucion