I am trying to set up Twilio to send a text once a new item is submitted on my app. Currently I am getting a
POST http://localhost:3000/sendtext 500 (Internal Server Error)
while trying to execute the script through the app.
Here is what I have in my 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.');
}
});
});
And here is what is in my controller:
$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: {}
})
};
This actually works through Postman. when I Post to the localhost location.