How can I call a parse background job from after save ?
Parse.Cloud.afterSave("test object", function(request) {
// I want to call a background job HERE
});
It want to fire this background job
Parse.Cloud.job("test job", function(request, status) {
// save all objects (huge save)
});
If I can't do that in the main.js cloud code, could I call a background job in the client side (JavaScript) ?
Thanks,
Apparently there is no way to do it via a javascript API call yet. In order to achieve this, I am using the REST api.
To get started, in case you've never done REST, here is something that was really helpful to debug for me: https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo Later you will call the function Parse.Cloud.httpRequest from Cloud code.
What you need to do is set the following:
url: https://api.parse.com/1/jobs/[your test job]
(maybe you need to encode the space to a %20 but I would recommend do start without spaces
method: POST
request header:
X-Parse-Application-Id: [your app id]
X-Parse-Master-Key: [your master key] //([find this here by selecting your app in the dropdown][3])
Content-Type: application/json
payload: {}
//(this will be your input data if you need some
This ways You can run a background job, but I still can't find a way to schedule it. Hope this help!