Reputation: 125
My Parse cloud code is structured like so:
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:
- (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. However, rather than logging "Successfully pinged eBay!", Parse is giving the following error: Error: function not found (Code: 141, Version: 1.2.18)
Upvotes: 2
Views: 12974
Reputation: 72
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. So my Cloud Code function didn't get uploaded to the app I was working on
Upvotes: 0
Reputation: 1411
Check your success Function. It is not calling `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".
Upvotes: 0
Reputation: 9942
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. It seems yours do not.
Upvotes: 4