Can not read item from Object queried from Moralis [solved]

hi Guys,
I have this cloud code to read Object from database:


const getAllFetchList = async () => {

  logger.info("Starting getAllFetchList");

  const TokenList = Moralis.Object.extend("TokenList");

  var query = new Moralis.Query(TokenList);

  query.limit(100);

  const fetchList = await query.find();

  logger.info("token queried = " + JSON.stringify(fetchList));

  logger.info(

    "getAllFetchList: fetchList[0] = " + JSON.stringify(fetchList[0])

  );
//getAllFetchList: fetchList[0] =
//{"tokenAddress":"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
//"tokenSymbol":"WBNB",
//"exchangeAddress":"0x10ED43C718714eb63d5aA57B78B54704E256024E",
//"factoryAddress":"0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73",
//"chain":"bsc","chain_name":"mainnet",
//"createdAt":"2021-08-27T13:08:33.595Z",
//"updatedAt":"2021-08-27T14:28:37.845Z","objectId":"RL2iqOBoA02mHmf8gTQrHAoy"}

  logger.info(

    "getAllFetchList: fetchList[0].tokenAddress = " + fetchList[0].tokenAddress

  );
//above line could not read the item  fetchList[0] .tokenAddress 

  logger.info("getAllFetchList finished");

  return fetchList;

};

screen shot attached.


How can I extract .tokenAddress from above fetchList ?

Hi,
Not sure if this is the solution: listname[0]["tokenAddress"]

No, I have tried, not works

It should be:
fetchList[0].get(โ€˜tokenAddressโ€™)
Problem solved

3 Likes