Javascript 使用云代码时,在then()中使用Parse Query
我似乎无法让这个简单的解析查询在我的云代码Javascript 使用云代码时,在then()中使用Parse Query,javascript,parse-platform,parse-cloud-code,Javascript,Parse Platform,Parse Cloud Code,我似乎无法让这个简单的解析查询在我的云代码then()中工作,但当我将代码放在这个函数中时,什么也没有发生。就测试而言,这些变量现在只是占位符,但我有一个默认的TestObject类,当您从一开始就开始解析时,您会得到这个类,但出于某种原因,它总是不返回任何内容 下面是我目前正在使用的完整函数 // Function which will get the data from all the links passed into the function Parse.Cloud.define("my
then()
中工作,但当我将代码放在这个函数中时,什么也没有发生。就测试而言,这些变量现在只是占位符,但我有一个默认的TestObject类,当您从一开始就开始解析时,您会得到这个类,但出于某种原因,它总是不返回任何内容
下面是我目前正在使用的完整函数
// Function which will get the data from all the links passed into the function
Parse.Cloud.define("myNews", function (request, response) {
var promises = _.map(import_io_keys, function (news_api_key) {
return Parse.Cloud.httpRequest({
method: 'GET',
url: "https://api.import.io/store/connector/" + news_api_key + "/_query?input=webpage/url:https%3A%2F%2Fwww.designernews.co%2Fnew&&_apikey=xxxxxxxxxxxxxxxxxx",
headers: {
'Content-Type': 'application/json;charset=utf-8'
}
}).then(function (httpResponse) {
result = JSON.parse(httpResponse.text);
var success = false;
var news_icon = "";
var news_source_name = "";
var query = new Parse.Query("TestObject");
query.find({
success: function(results) {
success = true;
news_icon = results[0].get("foo");
news_source_name = results[0].get("foo");
response.success("done" + news_icon);
},
error: function() {
success = false;
response.error("Query lookup failed");
}
});
for (var story in result.results) {
if(story.length > 0){
if (story["article_link/_text"] !== "" && story["article_link"] !== "" && story["article_time"] !== "") {
if(success){
// Do the stuff later
}
}
}
}
});
});
Parse.Promise.when(promises).then(function () {
console.log("Got all the stories");
response.success(newsJsonData);
}, function () {
response.error("No stories");
console.log("API KEY IS: " + request.params.keys);
});
});
当您调用云函数时,您的客户端收到什么响应消息?null、空字符串或其他内容?如何填充“newsJsonData”变量?@toofoo它不会从成功或错误中返回任何内容。此外,对于当前代码,newsJsonData目前并不重要。