Trying to require Twilio npm module with twilio = require('https://bundle.run/twilio@3.48.2')
which works, but when I try to pass it my Twilio credentials `{
const client = new twilio("my-account0sid, Secret(“TWILIO_AUTH_TOKEN”));
const messages = client.messages.list({limit: 20})
.then(messages => messages.forEach(m => console.log(m.sid)));
return messages;
}
I get
o.URL is not a constructor`
and haven’t found a way to import this to analyze previous text messages.
It seems that whatever was used by bundle.run to shim nodejs’ url
, did so for an older version where url.Url
was present, but not url.URL
:
My recommendation for debugging these types of issues in Observable would be:
- load your notebook, open dev tools
- enable “pause on exceptions” and “pause on caught exceptions” (important, because Observable catches all errors)
- rerun the cell that triggers the error
(While loading a notebook, only have both of those options enabled if you really must, because you’ll get a lot of noise.)
1 Like
By the way, there is already an issue for this problem on Github:
Please note that the maintainer advises against the use of the twilio package on the client side:
At a high-level, this repo should not be used in a client-side (React) app. Communicating with Twilio APIs requires auth which would be exposed to the end-user. Blog about this and how to re-architect: https://www.twilio.com/blog/send-an-sms-react-twilio