Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I call a cloud code function with parameters using the Javascript SDK

I know in the iOS sdk I can do it like this

[PFCloud callFunctionInBackground:@"email" withParameters:@{@"param1": @"quantity1, @"param2": @"quantity2} block:^(NSString *result, NSError *error) {
    if (error) {
        //error
    } else {
        // make sure the set the email sent flag on the object
        NSLog(@"result :%@", result);
    }
}];

but how would I do this with a Javascript function

like image 950
user379468 Avatar asked Sep 03 '15 21:09

user379468


1 Answers

Parse.Cloud implements run()...

Parse.Cloud.run("email", { param1:"quantity1", param2:"quantity2" }).then(function(result) {
    // make sure the set the email sent flag on the object
    console.log("result :" + JSON.stringify(result))
}, function(error) {
    // error
});
like image 71
danh Avatar answered Sep 21 '22 23:09

danh