解析Promises,destroyAll();不工作?

时间:2015-07-18 04:41:59

标签: javascript parse-platform

以下代码中的第二行未在云作业期间执行,为什么会出现这种情况?前一行运行良好。

Parse.Object.destroyAll(apples).then(function() {
  return Parse.Object.destroyAll(pears); //Destroy all pear objects.
}, function(error) {
  status.error("Failed to destroy all apples/pears.");
});

status.success("Successfully deleted " + results.length + " pears.");

1 个答案:

答案 0 :(得分:4)

你的status.success在destroyAll(梨)甚至有机会运行之前同步运行

以这种方式试试

Parse.Object.destroyAll(apples).then(function() {
    return Parse.Object.destroyAll(pears); //Destroy all pear objects.
}).then(function() {
    status.success("Successfully deleted " + results.length + " pears.");
}, function(error) {
    status.error("Failed to destroy all apples/pears.");
});