Node.js Twilio抛出500内部服务器错误

Node.js Twilio抛出500内部服务器错误,node.js,twilio,Node.js,Twilio,我正在尝试设置Twilio,以便在我的应用程序上提交新项目后发送文本。目前我得到了一份工作 POST http://localhost:3000/sendtext 500 (Internal Server Error) 试图通过应用程序执行脚本时 以下是我在app.js中的内容: var twilio = require('twilio'); var client = new twilio.RestClient('twilio stuff', 'twilio stuff'); app.pos

我正在尝试设置Twilio,以便在我的应用程序上提交新项目后发送文本。目前我得到了一份工作

POST http://localhost:3000/sendtext 500 (Internal Server Error)
试图通过应用程序执行脚本时

以下是我在app.js中的内容:

var twilio = require('twilio');
var client = new twilio.RestClient('twilio stuff', 'twilio stuff');

app.post('/sendtext', function(req, res){
    client.sendSms({
    to:'8888888888',
    from:'8888888888',
    body:'ahoy hoy! Testing Twilio and node.js'
}, function(error, message) {
    if (!error) {
        console.log('Success! The SID for this SMS message is:');
        console.log(message.sid);
        console.log('Message sent on:');
        console.log(message.dateCreated);
    } else {
        console.log('Oops! There was an error.');
    }
});
});
以下是我的控制器中的内容:

$scope.addTask = function(obj){
    obj.days = $scope.selectedDays;
    $scope.taskList.push(obj);
    tasks.add(obj);
    $scope.newTask = false;
    console.log(obj);
    console.log('addTask successfully called');
    $http({
        method: 'POST',
        url: 'http://localhost:3000/sendtext',
        data: {}
    })
};

这实际上是通过邮递员实现的。当我发布到localhost位置时。

即使文本已发送,Postman也会声明它无法获得响应,并且连接到localhost时出错。这可能有点麻烦-但我确实让它工作了,我将app.js更改为app.Post('/sendtext',api.sendtext)并在my api.js中创建了该函数,需要twilio和客户端。这是一个很糟糕的工作,但它目前正在发挥作用。就这一点而言,它现在正在发送多条短信,大约相隔2分钟。