另一个Parse'成功/错误未被称为'错误

时间:2015-10-28 01:23:47

标签: javascript ios parse-platform push-notification httprequest

我最近发布了一个与另一个Parse CloudCode方法有关的问题,如果错误被抛出 错误:成功/错误未被调用 。我再次遇到这个问题但是使用了不同的方法/场景。

Parse.Cloud.define("background", function(request, response) { var moments = require("cloud/moments.js"); var now = moments.moment(); var query = new Parse.Query("Group"); query.find({ success: function(results) { for (var i = 0; i < results.length; i++) { var object = results[i]; var events = object.get("Events"); var getUsers = false; for (var q = 0; q < events.length; q++) { var e = events[q]; if (e.get("date") == now) { getUsers = true; break; } } if (getUsers == true) { for (var q = 0; q < events.length; q++) { var e = events[q]; if (e.get("date") == now) { var relation = object.relation("created"); var partOne = e.get("name"); var outString1 = partOne.concat(" is now"); // generate a query based on that relation var query = relation.query(); Parse.Push.send({ where: query, // Set our Installation query data: { alert: outString1 } }, { success: function() { // Push was successful }, error: function(error) { // Handle error } }); var relation2 = object.relation("joined"); var partOnee = e.get("name"); var outString = partOnee.concat(" is now"); // generate a query based on that relation var query2 = relation.query(); Parse.Push.send({ where: query2, // Set our Installation query data: { alert: outString } }, { success: function() { // Push was successful }, error: function(error) { // Handle error } }); e.destroy(); } } } } } }); response.success(); });

由于此方法不仅涉及简单的查询和返回(因为它具有for循环等),我对如何实现Parse Promise

1 个答案:

答案 0 :(得分:-1)

Parse documentation非常清楚如何使用Promise以及如何使用.then()块重写金字塔代码。