首页 > 解决方案 > TypeError:无法读取 Nexmo API 中未定义的属性“发送”

问题描述

我正在尝试使用 Nexmo API 发送 WhatsApp 消息,但它抛出的异常是未定义的发送。

const nexmo = new Nexmo({
  apiKey: apiKey,
  apiSecret: apiSecret,
  applicationId: "*************",
  privateKey: "/****/private.key"
})

nexmo.channel.send(
  { "type": "whatsapp", "number": "**********" },
  { "type": "whatsapp", "number": "************" },
  {
    "content": {
      "type": "text",
      "text": "This is a WhatsApp Message sent from the Messages API"
    }
  },
  (err, data) => { 
    if (err) {console.log(err)}
      else
      {
        console.log(data)
      }
   }
);

发送消息异常...

TypeError: Cannot read property 'send' of undefined
    at Object.<anonymous> (*****/trail1.js:14:16)
    at Module._compile (module.js:652:30)


标签: node.jsnexmo

解决方案


推荐阅读