1

错误代码如下:

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

main.js

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

应用程序.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);
    });
});

main.js中定义的 Cloud Function不起作用或未成功调用。为了在back4app上运行,是否有任何依赖项需要在 main.js 中声明或什么?

4

1 回答 1

0

根据我对 Back4App 的 Cloud Code 函数的理解,您不需要在 main.js 中包含那个“函数(错误)。当函数出现问题时,错误处理将在您的日志中显示为错误代码。

我已经做了一些测试,我会将您的main.js示例更新为如下所示:

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

然后您的app.js将是有效的,您可以通过转到your_webhost.back4app.io/test或使用 REST API 来调用该函数。

于 2017-07-04T17:37:13.037 回答