2014-03-24 87 views
2

我解析雲代碼的結構如下所示:解析雲代碼給我代碼:141錯誤

Parse.Cloud.define("eBayCategorySearch", function(request, response) { 
      url = 'http://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=*APP ID GOES HERE*'; 

     Parse.Cloud.httpRequest({ 
      url: url, 
      params: { 
      'OPERATION-NAME' : findItemsByKeywords, 
      'SERVICE-VERSION' : '1.12.0', 
      'RESPONSE-DATA-FORMAT' : JSON, 
      'callback' : _cb_findItemsByKeywords, 
      'itemFilter(3).name=ListingType' : 'itemFilter(3).value=FixedPrice', 
      'keywords' : request.params.item, 

       // your other params 
      }, 
      success: function (httpResponse) { 
      // deal with success and respond to query 
}, 
      error: function (httpResponse) { 
       console.log('error!!!'); 
       console.error('Request failed with response code ' + httpResponse.status); 
      } 
     }); 
}); 

,我調用函數從我的iOS應用中,像這樣:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
    if (sender != self.nextButton) return; 
    if (self.itemSearch.text.length > 0) { 

     [PFCloud callFunctionInBackground:@"eBayCategorySearch" 
          withParameters:@{@"item": self.itemSearch.text} 
            block:^(NSNumber *category, NSError *error) { 
             if (!error) {NSLog(@"Successfully pinged eBay!"); 
             } 

            }]; 


    } 

    // Get the new view controller using [segue destinationViewController]. 
    // Pass the selected object to the new view controller. 

} 

本質是什麼我想要做的是將用戶輸入的任何搜索查詢輸入到itemSearch字段中,ping eBay的數據庫,然後返回結果最多的categoryID。但是,而不是記錄「成功ping通易趣!」,解析是給出以下錯誤:Error: function not found (Code: 141, Version: 1.2.18)

+0

雲功能不應該返回什麼嗎?像response.success(「something」);或任何你想返回... – Moonwalkr

回答

4

我猜這是功能本身有問題。我已經看到了這個錯誤信息的幾個例子,當時的確是功能故障,而不是丟失。

在雲代碼導,我發現這個例子:

Parse.Cloud.define("averageStars", function(request, response) { 
    var query = new Parse.Query("Review"); 
    query.equalTo("movie", request.params.movie); 
    query.find({ 
    success: function(results) { 
     var sum = 0; 
     for (var i = 0; i < results.length; ++i) { 
     sum += results[i].get("stars"); 
     } 
     response.success(sum/results.length); 
    }, 
    error: function() { 
     response.error("movie lookup failed"); 
    } 
    }); 
}); 

此函數調用response.success和response.error,取決於狀態。看來你沒有。

0

檢查您的成功功能。它不調用`response.success(); 。

也轉到儀表板,並檢查您的函數是否真的在main.js更新,因爲錯誤消息說「函數未定義」。

0

剛被發現自己。問題在我的情況是非常簡單的

使用parse new犯了一個錯誤,並最終創建了一個名爲「3」的新項目,而不是在列表中的第三個項目上工作。所以我的雲代碼功能沒有上傳到我正在處理的應用程序