trying CloudCode out for the first time and loving it.
I am writing an iOS app that passes phone numbers to CloudCode to see if a phone number already has the app.
The problem is its firing the success block before the queries finish. I am guessing I need to know how many queries there are and work out if on the last one? I also seen this .then function?
Parse.Cloud.define("processNumbers", function(request, response) {
Parse.Cloud.useMasterKey();
var phoneNumbers = request.params.phoneNumbers;
phoneNumbers.forEach(function(entry) {
var query = new Parse.Query(Parse.User);
//query.equalTo("username", entry);
query.find({
success: function(results) {
console.log("has app");
},
error: function() {
console.log("not found");
}
});
console.log(entry);
});
response.success(phoneNumbers);
});