[SOLVED] Invalid Cloud Function Error

I am trying to map user data to a profile component for each user that authenticates.

Here is the cloud function:

Moralis.Cloud.define("getUsers", async (request) => {
  const query = new Moralis.Query("_User");
  const results = await query.find({ useMasterKey: true });
  return results;
});

Here is the error logged in the admin dashboard.

2022-08-13T03:08:29.116Z - Error: Invalid function: “pluginsReady”
at handleCloudFunction (/moralis-server/lib/Routers/FunctionsRouter.js:201:13)
at /moralis-server/lib/PromiseRouter.js:85:20
at processTicksAndRejections (node:internal/process/task_queues:96:5)

2022-08-13T03:13:12.286Z - Error: Invalid function: “getUsers”
at handleCloudFunction (/moralis-server/lib/Routers/FunctionsRouter.js:201:13)
at /moralis-server/lib/PromiseRouter.js:85:20
at processTicksAndRejections (node:internal/process/task_queues:96:5)

Developer console is also showing POST 400 Error at server/functions/getUsers. When I click the error link it shows a json object with code 141 and error: invalid function \getUsers\

Thank you in advanced.

You can look in legacy interface to see if the cloud code looks as expected. You can get that error even when the function is not present in cloud code, or the cloud code is invalid, or the server is restarting.

1 Like

I went to the legacy cloud code UI.

The cloud function was not there. Maybe I am not using the right path in the CLI.

I copy/pasted my function into there and it is working as expected now. Thank you.

1 Like