简体   繁体   English

解析云代码给我代码:141错误

[英]Parse cloud code giving me Code: 141 error

My Parse cloud code is structured like so: 我的Parse云代码的结构如下:

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);
            }
       });
});

and I call the function from within my iOS app like so: 然后从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.

}

Essentially what I want to do is take whatever search query a user types into the itemSearch field, ping eBay's database, and return the categoryID with the most results. 本质上,我想做的是将用户键入的任何搜索查询输入到itemSearch字段中,对eBay的数据库执行ping操作,并返回结果最多的categoryID。 However, rather than logging "Successfully pinged eBay!", Parse is giving the following error: Error: function not found (Code: 141, Version: 1.2.18) 但是,而不是记录“成功ping通eBay!”,解析给出了以下错误: Error: function not found (Code: 141, Version: 1.2.18)

I'm guessing there is something wrong with the function itself. 我猜函数本身有问题。 I have seen several examples of that error message when indeed it was the function malfunctioning, not missing. 我确实看到了该错误消息的几个示例,但实际上是该函数出现了故障,没有丢失。

In the cloud code guide, I found this example: 在云代码指南中,我找到了以下示例:

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");
    }
  });
});

This function calls response.success and response.error, depending on state. 该函数根据状态调用response.success和response.error。 It seems yours do not. 看来你没有。

Check your success Function. 检查您的成功功能。 It is not calling `response.success(); 它没有调用`response.success();。 .

Also go to the dashboard and check if your function is really updated at main.js because the error message says that "function is not defined". 另外,请转到仪表板,并在main.js上检查您的功能是否真正更新,因为错误消息显示“未定义功能”。

Just been caught out myself. 刚刚被自己发现。 Problem in my case was very simple 我的问题很简单

Made a mistake using parse new , and ended up creating a new project called "3" rather than working on the 3rd project in the list. 使用parse new犯了一个错误,最终创建了一个名为“ 3”的新项目,而不是处理列表中的第3个项目。 So my Cloud Code function didn't get uploaded to the app I was working on 因此我的Cloud Code功能没有上传到我正在处理的应用程序中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM