Monday, 5 June 2017

Twilio TwimlResponse not a constructor

I have followed the other answers to this and have simplified my call down to this:

var http = require('http');
var twilio = require('twilio');
http.createServer(function (req, res) {
var resp = new twilio.TwimlResponse();
     resp.say({voice:'woman'}, 'ahoy hoy! Testing Twilio and node.js');
     res.writeHead(200, {
      'Content-Type':'text/xml'
     });
     res.end(resp.toString());
}).listen(1337);

This returns:

TypeError: twilio.TwimlResponse is not a constructor
at Server.<anonymous> (C:\Users\jmmann\Projects\node-sms\server.js:9:14)
at emitTwo (events.js:106:13)
at Server.emit (events.js:191:7)
at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:548:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)

Any idea/suggestions?



via John Mann

No comments:

Post a Comment