以下是我尝试部署的代码:
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
有关如何解决此问题的任何帮助?
答案 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。