Parse-sdk-js: RFE: Parse.Cloud.runJob

Created on 5 Oct 2017  路  4Comments  路  Source: parse-community/Parse-SDK-JS

Hi,
It would be great to be able to call a Job using the js sdk (using the masterkey, so from a Cloud hook or Function). It would remove the need to use a lib like 'request-promise' and simplify the way we send params.

Thx,
Olivier

pr-submitted

Most helpful comment

If anyone needs a Node.js example, here is my (modest) REST code:

const rp = require('request-promise');

async function runJob(jobName, params) {
    const options = {
        url: Parse.serverURL + '/jobs/' + jobName,
        headers: {
            'X-Parse-Application-Id': Parse.applicationId,
            'X-Parse-Master-Key': Parse.masterKey
        }
    };
    if (params) {
        options.json = params;
    }
    return rp.post(options);
}

All 4 comments

If anyone needs a Node.js example, here is my (modest) REST code:

const rp = require('request-promise');

async function runJob(jobName, params) {
    const options = {
        url: Parse.serverURL + '/jobs/' + jobName,
        headers: {
            'X-Parse-Application-Id': Parse.applicationId,
            'X-Parse-Master-Key': Parse.masterKey
        }
    };
    if (params) {
        options.json = params;
    }
    return rp.post(options);
}

@flovilmart Where is Parse.Cloud.job defined in the JS SDK? I can do a PR for this.

The job is not defined in the JS SDK, but by the server. If you plan to expose it, please make it only available for node and only with master Key

That won't be needed thanks.

Was this page helpful?
0 / 5 - 0 ratings