Moralis.Object.extend return undefined on Cloud function

I created a simple cloud function:

Moralis.Cloud.define("createBattle", async (request) => {
  var pendingBattle = Moralis.Object.extend("pendingBattle");
  return pendingBattle;


but when I try to call this, “pendingBattle” always undefined

can anyone help? Thanks.

I guess that you should use it in that could function and not return it or run it directly in front end, I don’t expect it to work how you wrote it.

Yes, I used it to create a new object, change data and save to the Database. But it throws an error, so I try to debug and find out it is undefined from the beginning.

you can paste the original error and code that you tried, it may be easier to identify what is not working