Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error en el wallet.service.ts no esta leyendo bien los datos de el endpoint all #3

Open
Cisco101010 opened this issue May 31, 2024 · 0 comments

Comments

@Cisco101010
Copy link

[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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant