![](/img/trans.png)
[英]Getting error while installing live-server package using npm. `npm audit` is not helping to fix the problem
[英]Getting error from server using nexmo npm package to send SMS
我正在使用nexmo
NPM 包。 我已经根据文档实现了所有事情,但是我从服务器收到了这个响应,并且没有发送 SMS。
{
"code": "ENOTFOUND",
"errno": "ENOTFOUND",
"syscall": "getaddrinfo",
"hostname": "rest.nexmo.com",
"host": "rest.nexmo.com",
"port": 443
}
我正在将其实现为Firebase Cloud Function 。 这是代码
exports.SMS = functions.https.onRequest((request, response) => {
console.log("This is the function");
console.log(request.body);
var json = JSON.parse(request.body);
const phone = json.phone;
console.log(phone);
const nexmo = new Nexmo({
apiKey: '******',
apiSecret: '*********'
});
const from = '12017016978';
const to = phone;
const text = 'Thank You for using TPV Express. Please use the following link to download our voice-enabled Android app for Third Party Verification. https://play.google.com/store/apps/details?id=com.patientdatascience.tpvexpress&hl=en';
nexmo.message.sendSms(from, to, text, (error, res) => {
if(error) {
// throw error;
console.log(error);
response.json({success: false,data: error});
} else if(res.messages[0].status != '0') {
console.error(res);
response.json({success: false,data: res});
// throw 'Nexmo returned back a non-zero status';
} else {
console.log(res);
response.json({success: true,data: res});
}
});
});
我想通了是什么问题。 它不适用于 nexmo npm 包。 问题是我正在使用 firebase 的 spark 计划,而这个免费计划不允许我们从该函数调用第三方 API。
我升级到 Blaze 计划并解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.