I'm saving three results but they are all the same. I'm running into the dam Javascript async loop problem. How do I get out of this?
my code:
var teamMatch = function(){
var Pairingteam = [];
var promise = Parse.Promise.as();
var x = matchedPairingIds.length;
while (x--) {
var match = matchedPairingIds[x];
var matching = function () {
matched.set("team", {
__type: "Pointer",
className: "_User",
objectId: "yCDDEWoiwM"
});
matched.set("Pairing", {
__type: "Pointer",
className: "Pairing",
objectId: match
});
Pairingteam.push(matched.save());
}
}
promise.then(function(){
return Parse.Promise.when(Pairingteam);
});
}
teamMatch();