How do I construct Twilio.Response?

170 views
Skip to first unread message

Trevor

unread,
Jul 27, 2020, 12:11:55 PM7/27/20
to Twilio Functions
The Functions documentation outlines how to create a Twilio Response object here: https://www.twilio.com/docs/runtime/functions/invocation#constructing-a-response

The issue I'm having is that the latest twilio NPM package (v3.48.1 - https://github.com/twilio/twilio-node/) does not expose a Twilio.Response object and attempting to create a `new Twilio.Response()` results in a "TypeError: Twilio.Response is not a constructor" error.

I am attempting to use the Response object to send CORS headers as described here: https://www.twilio.com/docs/runtime/functions/faq#how-do-i-send-cors-headers

What is the correct way to create a Twilio.Response for use within a Twilio Function?

Trevor

unread,
Jul 27, 2020, 12:25:43 PM7/27/20
to Twilio Functions
After some additional testing, Twilio.Response appears to only be available from the twilio package used within the Twilio Runtime and not from the public twilio NPM package.

Malcolm Elavia

unread,
Aug 5, 2020, 1:01:49 PM8/5/20
to Twilio Functions
Isn't Response the Twiml verb for Message? I think you have to use MessageResponse when responding and create when making a new message when using API?
I hope this helps - I'm a newbie so if I don't make any sense that is why =)
Reply all
Reply to author
Forward
0 new messages