function bsfir() {
Parse.Promise.as().then(function() {
return Parse.Cloud.run('gRFI', {});
}).then(function(gRFIr) {
return Parse.Cloud.run('gFI', { });
}).then(function(gFIR) {
return gFIR;
}, function(error) {
return error;
});
}
Parse.Cloud.define("bSFI", function(request, response) {
Parse.Promise.as().then(function() {
return bsfir();
}).then(function(bsfirr) {
response.success(bsfirr);
}, function(error) {
response.error("219 error: " + JSON.stringify( error));
});
});
The goal is to have bsfir()
complete execution (i.e. resolve the promise) before handing execution back to the caller, in this case, bSFI()
.
Calling bSFI()
results in executing only a few lines of code in bsfir()
. The execution of bSFI()
completes almost immediately/instantaneously probably because the promise in bsfir()
isn't tied to a return value so when bSFI()
calls bsfir()
, execution immediately goes to response.success(bsfirr);
Is using Promise.all()
in bsfir()
a good solution?