objective c - Parse Cloud Code query not getting executed -
i have below cloud code function , when call function os x app, success response well. none of console log output messages inside success , failure blocks of query operation gets executed. ideas on appreciated.
parse.cloud.define("markalertasexpired", function(request, response) { parse.cloud.usemasterkey(); var alert = parse.object.extend("alert"); var query = new parse.query(alert); query.get("vc6ppoxuqd", { success: function(alertobj) { // object retrieved successfully. var status = alertobj.get("status"); console.log("received object status:"); console.log(status); if (status == "active") { console.log("active"); markactivealertasexpired(alertobj); } else if (status == "inactive") { console.log("inactive"); markinactivealertasexpired(alertobj); } else { console.error("unknown_status"); } }, error: function(object, error) { // object not retrieved successfully. // error parse.error error code , message. console.error("alert_not_found"); response.error("alert_not_found"); } }); response.success("available"); });
you need wait queries complete before calling response.success, updated code below should work.
parse.cloud.define("markalertasexpired", function(request, response) { parse.cloud.usemasterkey(); var alert = parse.object.extend("alert"); var query = new parse.query(alert); query.get("vc6ppoxuqd", { success: function(alertobj) { // object retrieved successfully. var status = alertobj.get("status"); console.log("received object status:"); console.log(status); if (status == "active") { console.log("active"); markactivealertasexpired(alertobj); } else if (status == "inactive") { console.log("inactive"); markinactivealertasexpired(alertobj); } else { console.error("unknown_status"); } response.success("available"); }, error: function(object, error) { // object not retrieved successfully. // error parse.error error code , message. console.error("alert_not_found"); response.error("alert_not_found"); } }); });
Comments
Post a Comment