Return HTTP response earlier in Parse.Cloud.define

Hi Parse Community,

I defined a custom cloud method using Parse.Cloud.define that perform the deletion of a user’s account.
Even tho I can perform the deletion of all user’s entries without any problem, I would like to perform this in background and just return HTTP 200 as soon as possible to unblock users on the client side.

How can I perform a res.send(200) in a cloud function?

Thank you in advance for your help.

You can do something like this:

Parse.Cloud.define('myFunction', () => {
  doSomethingAsyncStuff();
});

since you are not awaiting doSomethingAsyncStuff, the cloud function will responde immediately.

Another option (which I’d prefer), would be not awaiting the cloud code function call in the client.

Ah! Right! That’s all you need. Thanks @davimacedo :smiley:

Another option (which I’d prefer), would be not awaiting the cloud code function call in the client.

We don’t want that tho. It’s preferable to make sure that the backend was reached before logging out the user. We need to wait for an HTTP 200 response.