We are sometimes getting an 'Uncaught undefined' error from one of the beforeSave functions in cloud code. Majority of the time, the beforeSave runs fine. Even when it fails with the uncaught undefined error, the next attempt to save works fine. What could cause the 'Uncaught undefined' error?
Here is the error from the Parse error console: Result: Uncaught undefined
Also the error seems to be random.
Here is the code:
Parse.Cloud.beforeSave("OurClass", function(request, response){
var objId = request.object.id;
return Parse.Promise.as() .then(function(){
var key = request.object.get("key"); //'key' is a Pointer to an obj in another class
if (key){
return externalFunc(request);//This fn returns a promise
}
else {
return Parse.Promise.error("Key Obj does not exist for objId");
}
}).then(function(){
response.success();
},
function(err) {
response.error("Err: " + err);
});
});