javascript - TypeError:无法读取未定义 Fast2sms 的属性“加入”
问题描述
我正在尝试在 nodejs 中使用 fast2sms 发送短信,但我遇到了一些问题。
错误类似于:TypeError: Cannot read property 'join' of undefined at Object.sendMessage (C:\Users\user\Desktop\node_modules\fast-two-sms\index.js:37:27)
这是我的代码:
try {
const type = 'phone'
res.render('verify', {
'type': type
})
console.log(phone)
await fastTwoSms.sendMessage({
authorization: process.env.API_KEY,
message: `Your Otp is ${otp}`,
number: [phone]
})
} catch (error) {
next(error)
}
解决方案
根据您的错误,我检查了图书馆
(https://github.com/raxraj/fast-two-sms/blob/master/index.js)
在第 37 行。
let url = 'https://www.fast2sms.com/dev/bulk';
let nums = props.numbers.join(',');
它期望numbers
输入键不是number
。
只需将数字更改为数字即可。
await fastTwoSms.sendMessage({
authorization: process.env.API_KEY,
message: `Your Otp is ${otp}`,
numbers: [phone]
})
推荐阅读
- dotspatial - 如何从 DemoMap DotSpatial 程序中的插件访问地图控件
- python - 支持英特尔 MKL 的 Python3 numpy [Win10]
- python - Python3中字符串数字列表的排序列表?
- sql-server - 从另一个表插入列值:无法绑定多部分标识符
- python - 使用 Python 合并具有多个键的两个电子表格的最佳方法
- android - React Expo WebView不播放视频只有声音
- java - 在无效的源版本级别 13 启用预览功能,预览只能在源级别 14Java 启用 (2098258)
- python - 如何使用管道对嵌入在 OneVsRestClassifier 中的估计器进行网格搜索
- java - Tomcat:Java Webservice 部署不工作 - 状态 404
- identityserver4 - 在 Linux 上托管 IdentityServer 4