生成客户端令牌时出错(PayPal和Firebase功能)

时间:2018-05-18 20:32:27

标签: node.js firebase google-cloud-functions braintree

以下是我尝试部署的代码:

exports.generateToken = functions.https.onRequest((request, response) => {
    gateway.clientToken.generate({ }, function (err, response) {
        var clientToken = response.clientToken;
        response.send(clientToken);
    });
});

这是部署期间生成的错误消息:

  10:36  error    Expected error to be handled    handle-callback-err
  10:36  warning  Unexpected function expression  prefer-arrow-callback

有关如何解决此问题的任何帮助?

1 个答案:

答案 0 :(得分:2)

缺少错误处理导致了问题。添加以下行后,我能够成功部署:

exports.generateToken = functions.https.onRequest((request, response) => {
    gateway.clientToken.generate({ }, function (err, response) {
        // error has to be handled
        if(err) {
           // handle error here
        } else {
           var clientToken = response.clientToken;
           response.send(clientToken);
        }
    });
});

其他信息为here