Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/411.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么用Twilio获得意外的令牌?_Javascript_Error Handling_Twilio - Fatal编程技术网

Javascript 为什么用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

给定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 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));