Problem with displaying NFT information separately

Hello everyone,

I am having an issue with the NFT Gating tutorial template.

I built my site using it and would like to display the information about the NFT separately, however at the end of the code it generates an nftList, which when displayed presents all the information about it together all at once, and I don’t know how to select a specific part of that result to be able to display it separately.

In an attempt to better explain the situation, following the tutorial the result appears like this:

And what I am trying to display is only the part in red (without the quotes). Is there any way to do this? And if there is, could someone show/explain me how?

I apologize if the question is too basic, but I am a beginner.

Thank you very much.

You can run a map on the array to remove other parts

try result[0].get("token_address") or a similar syntax

I am sorry about this but, would you mind giving me an example/help on how to map this? Because I don’t know how to do it.

Thank you so much.

I am sorry Cryptokid, but how can I implement this?

Assume result is the data

let result = [
  {
    token_address: "0xf39Fd67...79cffFb92266",
    token_id: "1",
    amount: "1",
    contract_type: "ERC721",
  },
];

let token_address = result[0].token_address;
// 0xf39Fd67...79cffFb92266

let tokenAddressArray = result.map((resultObj) => {
  return { token_address: resultObj.token_address };
});
// [ { token_address: '0xf39Fd67...79cffFb92266' } ]

You got such using either of the above mentioned way

Qudusayo this actually solves the problem, but it seems to create a new one. Because the person who does not have NFT instead of getting the message “Sorry, you don’t have our NFT”, gets an error. How can I solve this?

You could add ? after nftList[0] before . having for example nftList[0]?.token_address. You can read about optional chaining here