2014-03-24 43 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”的新项目,而不是在列表中的第三个项目上工作。所以我的云代码功能没有上传到我正在处理的应用程序