diff --git a/spec/ParseAPI.spec.js b/spec/ParseAPI.spec.js index 52c17fbfed..626892a9b1 100644 --- a/spec/ParseAPI.spec.js +++ b/spec/ParseAPI.spec.js @@ -732,4 +732,14 @@ describe('miscellaneous', function() { }); }); + it('fetches the config using a promise', done => { + Parse.Cloud.run('PromiseWithoutRejectedCallbackFail').then((s) => { + expect(s instanceof Object).toBe(true); + expect(s.config instanceof Object).toBe(true); + done(); + }, (e) => { + fail(e); + }); + }); + }); diff --git a/src/cloud/main.js b/src/cloud/main.js index fec259910a..5ecc3991da 100644 --- a/src/cloud/main.js +++ b/src/cloud/main.js @@ -102,3 +102,20 @@ Parse.Cloud.define('requiredParameterCheck', function(req, res) { }, function(params) { return params.name; }); + +Parse.Cloud.define("PromiseWithoutRejectedCallbackFail", function(request, response) { + var promises = []; + var result = {}; + + // fetch config + result.config = {}; + + promises.push(Parse.Config.get().then(function(config) { + result.config = config.attributes; + })); + + // wait for all promises to finish + Parse.Promise.when(promises).then(function() { + response.success(result); + }); +});