我有一个解析云代码函数,我正在使用该函数从我的一个名为SourcesTopData的类中获取一些信息,如下图所示,每当应用程序启动时,都会迅速调用它。
我遇到的问题是我用来获取此信息的查询代码似乎无法正常工作。使用的功能如下。
Parse.Cloud.define("myNews", function (request, response) {
var newsJsonData = {
"stories": []
};
// Check the params and get the range
if (parseInt(request.params.myoffset) === 0) {
endIndex = 5;
} else {
startIndex = request.params.myoffset;
endIndex = startIndex + 5;
}
var promises = _.each(request.params.keys, function (news_api_key) {
if (request.params.Type == "Top") {
var query = new Parse.Query("SourceTopData");
query.equalTo("guid", news_api_key);
console.log("The api key is " + news_api_key);
query.find({
success: function (results) {
console.log("The results are");
console.log("The icon name is " + results[0].get("icon") + " The source name is " + results[0].get("source") + " The url id is " + results[0].get("guid_url"));
},
error: function () {
console.log("FAIL");
success = false;
response.error("Query lookup failed");
}
});
}
});
Parse.Promise.when(promises).then(function () {
response.success(newsJsonData);
}, function () {
response.error("No stories");
});
});
我尝试在
console.log("The results are");
下记录列的行没有打印任何内容。移动日志记录后,我发现该代码未在查询中成功或失败,但是我似乎无法弄清楚为什么这是因为查看文档后我已经设置了正确。 最佳答案
您没有为诺言处理返回任何东西:
return query.find({
关于swift - 解析云代码查询未触发成功或错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35563720/