这是一个奇怪的错误消息。
据我所知...
在第 89 行和第 90 行之间插入:
}, function() {
return Parse.Promise.as();//return resolved promise to keep the promise chain going.
给予:
return Parse.Cloud.httpRequest({
url: url,
//data: ... //some properties of menuItem?
}).then(function(httpResponse) {
return readResponse_async(httpResponse.text).then(function(res) {
if (res.menu.day.at(dayNumber).meal) {
return saveMeals_async(res.menu.day.at(dayNumber).meal, school, diningHallNumber, menuLocation);
} else {
return Parse.Promise.as();//return resolved promise to keep the promise chain going.
}
}, function() {
return Parse.Promise.as();//return resolved promise to keep the promise chain going.
});
});
或者可能低一行:
return Parse.Cloud.httpRequest({
url: url,
//data: ... //some properties of menuItem?
}).then(function(httpResponse) {
return readResponse_async(httpResponse.text).then(function(res) {
if (res.menu.day.at(dayNumber).meal) {
return saveMeals_async(res.menu.day.at(dayNumber).meal, school, diningHallNumber, menuLocation);
} else {
return Parse.Promise.as();//return resolved promise to keep the promise chain going.
}
});
}, function() {
return Parse.Promise.as();//return resolved promise to keep the promise chain going.
});
EDIT
由于这两个都未能处理错误,您可以尝试这个,这很混乱,但可以容忍,如果我怀疑 Parse 的承诺不是“抛出安全”:
return Parse.Cloud.httpRequest({
url: url,
//data: ... //some properties of menuItem?
}).then(function(httpResponse) {
try {
return readResponse_async(httpResponse.text).then(function(res) {
if (res.menu.day.at(dayNumber).meal) {
return saveMeals_async(res.menu.day.at(dayNumber).meal, school, diningHallNumber, menuLocation);
} else {
throw new Error();
}
});
}
catch(e) {
return Parse.Promise.as();//return resolved promise to keep the promise chain going.
}
}, function() {
return Parse.Promise.as();//return resolved promise to keep the promise chain going.
});