1

I am programming in React Native and I'm having a problem because I have this response from an api request:

  "payload": [
    {
      "txid": "ace6f04e13d4c9482dec860eeccab59e5bf50bfd8bf966ab179131c0b218d5e8",
      "amount": 0.00015802,
      "fee": 0.00015198,
      "unit": "btc",
      "datetime": "2020-03-04 11:25:57 UTC",
      "timestamp": 1583321157,
      "confirmations": 502,
      "sent": {
        "mnetBQ8h3srGd3oNT4uczwcQpXjR6AE73E": 0.00021,
        "n1s4jV66dGSX6TDezLRWZgcEuH5Sy2Pujg": 0.0001
      },
      "received": {
        "mnetBQ8h3srGd3oNT4uczwcQpXjR6AE73E": 0.00015802
      }
    },
    {
      "txid": "ffa143f44b114be4db0091500ab189c5d50f29758970a54e7a1dc08c2b47ea50",
      "amount": 0.11484588,
      "fee": 0.00000168,
      "unit": "btc",
      "datetime": "2020-03-03 09:20:12 UTC",
      "timestamp": 1583227212,
      "confirmations": 728,
      "sent": {
        "2NCJCzQFPANPkRmYDidKcUao9c9fLp5HeXV": 0.11484756
      },
      "received": {
        "n1s4jV66dGSX6TDezLRWZgcEuH5Sy2Pujg": 0.0001,
        "2NDEprTde2Uci9zqNVNWc1eXkCe8NENi3gY": 0.11474588
      }
    }
  ],
  "meta": {
    "totalCount": 4,
    "index": 0,
    "limit": 50,
    "results": 4
  }
} 

And I also have a const with my address value inside it: const address = "mnetBQ8h3srGd3oNT4uczwcQpXjR6AE73E"

For example how can I access to payload[0].sent.mnetBQ8h3srGd3oNT4uczwcQpXjR6AE73E ? Because if I try with payload[0].sent.address I get undefined.

Thanks for help.

Enricopro
  • 11
  • 1

1 Answers1

0

You can do it like this

payload[0].sent[address]
Ali Hayder
  • 315
  • 1
  • 9