Javascript 为什么用Twilio获得意外的令牌?
给定Twilio中的示例代码:Javascript 为什么用Twilio获得意外的令牌?,javascript,error-handling,twilio,Javascript,Error Handling,Twilio,给定Twilio中的示例代码: const accountSid = 'ACf37a37065e79fb1a7a594f294cb3b190'; const authToken = 'your_auth_token'; const client = require('twilio')(accountSid, authToken); client.messages .create({ body: 'This is the ship that made the Kessel Run
const accountSid = 'ACf37a37065e79fb1a7a594f294cb3b190';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);
client.messages
.create({
body: 'This is the ship that made the Kessel Run in fourteen parsecs?',
from: '+15017122661',
to: '+15558675310'
})
.then(message => console.log(message.sid));
如何获取错误代码和错误消息
以下是输出(根据快速指南)
我正在尝试这个:
client.messages
.create({
body: 'This is the ship that made the Kessel Run in fourteen parsecs?',
from: '+15017122661',
to: '+15558675310'
})
.then(message => console.log(message.sid));
.then(message => console.log(message.error_code));
但是不起作用。我得到了意想不到的代币。
理想情况下,我希望记录错误代码和消息以及其他信息,如发送日期等。。因此,我验证并将正确的信息发送回客户机
任何帮助都将不胜感激
谢谢您得到了
令牌
东西,因为您在这两个之间有一个分号then()
(注意下面代码中第一行的末尾和第二行的开头)
就这样!非常感谢你!
client.messages
.create({
body: 'This is the ship that made the Kessel Run in fourteen parsecs?',
from: '+15017122661',
to: '+15558675310'
})
.then(message => console.log(message.sid));
.then(message => console.log(message.error_code));
.then(message => console.log(message.sid)); // <----
.then(message => console.log(message.error_code));