2016-01-16 16 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