M. Alves
M. Alves

Reputation: 45

How can I call a function using parse-server

I'm developing a JavaScript web app, and I'm trying to make a "forgot password" feature. I know how to make a function on the server-side, in the Cloud code with Parse function. But what I can't do is pass the object from my controller (in the front-end side). By the way, I'm using ember.js.

I've tried to save ("user.save()") the object (even without changing anything) and then calling Parse.Cloud.AfterSave("user",(request){..}), but I was getting a error. How can I pass an object to the Cloud code?

Upvotes: 3

Views: 1250

Answers (1)

Davi Macêdo
Davi Macêdo

Reputation: 2984

In your main.js file, in order to create a cloud code function:

Parse.Cloud.define('resetPassword', async req => {
  console.log(`My user is: ${req.object.getUsername()}`);
  ...
});

In your client code, in order to call the cloud code function:

await Parse.Cloud.run('hello', { user: Parse.User.current() });

Upvotes: 2

Related Questions