解析云函数不会 return response.success
Parse Cloud Function won't return response.success
我的云函数调用我托管的网络爬虫并检索回字符串,但如果字符串很长(它只适用于短字符串),我无法 response.success 将字符串返回到我的应用程序因为某些原因)。这是我的代码:
Parse.Cloud.define("search", function(request, response){
Parse.Cloud.useMasterKey();
Parse.Cloud.httpRequest({
url: 'https://xxx.herokuapp.com/',
params: {
keyword: request.params.searchTerm
},
success: function(httpResponse){
// The httpResponse.text is received but for some reason
// will not be returned with response.success
response.success(httpResponse.text);
}, error: function(httpResponse){
response.error(httpResponse);
}
});
});
几天来我一直被这个问题困扰,如果能提供任何帮助,我们将不胜感激。
我犯了一个愚蠢的错误,似乎只需要在将字符串返回给应用程序时执行以下操作:
response.success(JSON.parse(httpResponse.text));
我不确定为什么需要使用较长的字符串来完成此操作,而使用较短的字符串似乎无关紧要,但我确定这是有原因的。
我的云函数调用我托管的网络爬虫并检索回字符串,但如果字符串很长(它只适用于短字符串),我无法 response.success 将字符串返回到我的应用程序因为某些原因)。这是我的代码:
Parse.Cloud.define("search", function(request, response){
Parse.Cloud.useMasterKey();
Parse.Cloud.httpRequest({
url: 'https://xxx.herokuapp.com/',
params: {
keyword: request.params.searchTerm
},
success: function(httpResponse){
// The httpResponse.text is received but for some reason
// will not be returned with response.success
response.success(httpResponse.text);
}, error: function(httpResponse){
response.error(httpResponse);
}
});
});
几天来我一直被这个问题困扰,如果能提供任何帮助,我们将不胜感激。
我犯了一个愚蠢的错误,似乎只需要在将字符串返回给应用程序时执行以下操作:
response.success(JSON.parse(httpResponse.text));
我不确定为什么需要使用较长的字符串来完成此操作,而使用较短的字符串似乎无关紧要,但我确定这是有原因的。