Search code examples
javascriptparse-platformsdkparse-cloud-code

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


Solution

  • 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
    });