2

The error code is below:

{"code":141,"message":"Invalid function: \"test\""}

main.js

 Parse.Cloud.define('test', function(request, response){
     response.success('OK');
 }, function(error){
     response.error(error);
 });

app.js

app.get('/test', function(req, res){
    Parse.Cloud.run('test', null).then(function(result){
        return res.send(result);
    }, function(error){
        return res.status(400).send(error);
    });
});

The Cloud Function defined in main.js does not work or isn't called successfully. Are there any dependencies missing to be declared in main.js in order to run on back4app or what?

nonkertompf
  • 387
  • 1
  • 3
  • 12
  • Not sure if back4app handles this differently, but it sounds like your main.js file isn't being included correctly. Are you sure your include path in your app.js file is correctly finding the main.js file? – EReid Feb 02 '17 at 08:03
  • I didn't know that we need to include the main.js file. Do we need to? – nonkertompf Feb 02 '17 at 12:38
  • Sorry, I may have used the wrong wording there. In the main app file, when configuring the Parse Server, there is an option to set the main Cloud function file. As so: `var api = new ParseServer({ cloud: (process.env.CLOUDPATH) ` Is that path correct in your case? – EReid Feb 02 '17 at 12:41
  • I'm sorry but I really don't understand one thing here. Back4app Parse Server is configured and handed in ready for you to just deploy your files. For example; when I make a parse query, it works without ever configuring parse server. I'm not sure if I still have to define any paths to the main.js file where cloud functions are meant to be. Are you? – nonkertompf Feb 02 '17 at 13:10
  • Right, I'm unaware how back4app works, so you might be right. In that case, I'll probably be unable to help further. – EReid Feb 02 '17 at 14:04

1 Answers1

0

From what I could understand regarding Back4App's Cloud Code functions you won't need to have that "function(error)" within your main.js. The error treatment will be represented as an error code in your logs when the function present a problem.

I've done some tests and I'd update your example of main.js to be simple like this:

Parse.Cloud.define('test', function(request, response){
     response.success('OK');
 });

Then your app.js would be valid and you could call that function simply by going to your_webhost.back4app.io/test or using REST API.

Casagrande
  • 90
  • 7