[SOLVED] Live Query doesn't return attributes

Hi,

I was following a guide on Live Queries, so I got working that when a record gets created a function is called.

init = async () => {
  console.log("I have been summoned!");
  let query = new Moralis.Query("KekwTokenEvents");
  let subscription = await query.subscribe();
  subscription.on("create", onTokenMint);
  getImage();
};

onTokenMint = (token) => {
  try {
    console.log(token);
    console.log("Minting... Token ID:" + token.attributes.ID);
    //uploadMetadata(token.attributes.ID);
  } catch (err) {
    console.log("Error Occured: ");
    console.log(err);
  }
};

When going into the onTokenMint function and passing the token. I only get the following object returned:

image

It has no attributes array, while in the database it does have attributes:

How do I get the object with attributes?

For me it looks to give me the attributes for a simple table.
You try here: token.attributes.ID but you have tokenID in that print screen.

2 Likes

Ofcourse, what a typo :sweat_smile: I was wondering why should have done token.attributes.tokenID

1 Like