1
I am unable to recover the value of the variable countEventChecks after Success. How can I assign the value of a return to another variable?
for (var x = 0; x < eventosCkeckedPeloUser.length; x++) {
if (eventosResponse[i].id == eventosCkeckedPeloUser[x].id) {
confirmCheck = true;
evento = {
"id": eventosResponse[i].id,
"img": eventosResponse[i].get("eve_imagem"),
"checks": countChecks(eventosResponse[i]),
"userCheck": confirmCheck
}
$scope.eventos.push(evento);
}
}
function countChecks(evento) {
var relation = evento.relation("eve_users");
var query = relation.query();
query.count({
success: function (res) {
return res;
}
});
}
I’ve tried it this way but it’s returning Undefined. When I put console.log(res) inside Success it prints the correct value. But when I invoke the Function countChecks(event) out the return is Undefined.
– David Coelho
You need a synchronous call, I edited the script, make sure it works.
– Vinicios Yals
I think I still don’t understand. I edited the code to see where to call the function.
– David Coelho
I reissued the code complementing with your edition, check that I will explain what I did depending on the result
– Vinicios Yals
Well, it keeps printing Undefined. But I think it’s something of Parse’s. I must be making a wrong call. I’ll study Parse some more. Thank you.
– David Coelho