2016-01-16 14 views
0

我的云端函数调用一个网络爬虫我托管和检索一个字符串回来,但我不能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); 
     } 
    }); 
}); 

我一直坚持这个问题几天,任何帮助将不胜感激。

回答

0

我犯了一个愚蠢的错误,一切似乎需要的是下面的返回字符串到应用程序时:

response.success(JSON.parse(httpResponse.text)); 

我不知道为什么这需要较长的字符串做,它不这似乎与短弦有关系,但我确信有一个原因。

+0

这实际上会导致未捕获的SyntaxError:<未知文件>中的意外标记S在某些字符串中不是其他字符。这是什么意思? – thailey01