我正在关注 NodeJS Twilio SDK 文档,内容如下:
const twilio = require('twilio')
exports.sendActivationCode = async (phone, activationCode) => {
const accountSID = '<REDACTED>'
const authToken = '<REDACTED>'
const client = twilio(accountSID, authToken)
return await client.messages.create({
body: `Your activation code is ${activationCode}`,
from: '+1<REDACTED>',
to: `+1${phone.toString().replace(/\D/g, '')}`
})
}
我已经检查了很多次,以确保我与文档直接匹配。当我尝试运行我得到的代码时Error: Headers User-Agent forbidden
。请求本身显示 header is out:'User-Agent': 'twilio-node/3.45.0 (node.js v10.15.3)'
并且堆栈输出表明这是来自jsdom
-> xhr-utils
。