Cloud Function error - does not work afterSave for Moralis.User

Hey guys
I am going to add new row in customized NftUser class when added new row in User class.
So I wrote the cloud function as follow:

Moralis.Cloud.afterSave(Moralis.User, async (request) => {
    const logger = Moralis.Cloud.getLogger();
    logger.info("added new user"); 
})

But it does not work.
What should I do?

https://docs.moralis.io/moralis-server/cloud-code/triggers#consequences-for-triggers
code looks like this:

Moralis.Cloud.afterSave("EthTransactions", async function(request) {
  const confirmed = request.object.get("confirmed");
  if (confirmed) {
    // do something
  } else {
    // handle unconfirmed case
  }
});

Hey @cryptokid
Thanks for your reply.
https://docs.moralis.io/moralis-server/cloud-code/triggers#aftersave
But for PREDEFINED CLASSES, we should not pass a string for the first argument. Instead, we should pass the class itself, for example:

Moralis.Cloud.afterSave(Moralis.User, async (request) => {
    // code here
})

User class is the predefined class. right?

1 Like

Hey @yuki

Try to use it this way:

Moralis.Cloud.afterSave("Users", async (request) => {
    // code here
})