Closed lakshminagandla closed 3 years ago
I have tried with below versions
node: 12.18.3 npm: 6.14.6 twilio: 3.63.0
We got below error message:
url.URL is not a constructor node_modules/twilio/lib/rest/Twilio.js:261:1 259 | } 260 |
261 | var uri = new url.URL(opts.uri); | ^ 262 | uri.hostname = this.getHostname(uri.hostname, this.edge, this.region); 263 | 264 | return this.httpClient.request({
Printing stack trace:
at Twilio.request (webpack:///node_modules/twilio/lib/rest/Twilio.js:261:1) at Api../node_modules/twilio/lib/base/Domain.js.Domain.request (webpack:///node_modules/twilio/lib/base/Domain.js:34:1) at V2010../node_modules/twilio/lib/base/Version.js.Version.request (webpack:///node_modules/twilio/lib/base/Version.js:45:1) at V2010../node_modules/twilio/lib/base/Version.js.Version.page (webpack:///node_modules/twilio/lib/base/Version.js:154:1) at Function.page (webpack:///node_modules/twilio/lib/rest/api/v2010/account/message.js:355:1) at apply (webpack:///node_modules/lodash/lodash.js:488:1) at wrapper (webpack:///node_modules/lodash/lodash.js:5379:1) at fetchNextPage (webpack:///node_modules/twilio/lib/rest/api/v2010/account/message.js:217:1) at Function.each (webpack:///node_modules/twilio/lib/rest/api/v2010/account/message.js:243:1) at Function.list (webpack:///node_modules/twilio/lib/rest/api/v2010/account/message.js:305:1)
Please suggest the solution
Hi @LakshmiNagandla are you using twilio-node in a client side app? Twilio-node should not be used in a client-side app since communicating with Twilio APIs requires auth. These credentials could be exposed to the end-user. Here's a blog about this and how to re-architect: twilio.com/blog/send-an-sms-react-twilio
@JenniferMah, We are trying to read the messages that are received to the Twilio number. While we are using APIs to read the data we are getting the above issue that we are mentioned.
But now at this moment, we are able to resolve the issue with a small update on the library side. Seems inside the Twilio library, we have noticed below the "Twilio.js" file, we are calling "var uri = new url.URL(opts.uri);"
File location: Twilio.request (webpack:///node_modules/twilio/lib/rest/Twilio.js:261:1)
Here we just tweaked the code like "var uri = new URL(opts.uri);" and now the library started working without any issues.
Thanks for your response and due to priority tasks we are unable to acknowledge you.
Thanks & Regards, Lakshmi
@SavvasLakshmiNagandla can you clarify if you are using the node helper in a client side app?
Closing due to inactivity. Feel free to reopen if further help is needed.
I have tried with below versions
node: 12.18.3 npm: 6.14.6 twilio: 3.63.0
We got below error message:
url.URL is not a constructor node_modules/twilio/lib/rest/Twilio.js:261:1 259 | } 260 |
Printing stack trace:
at Twilio.request (webpack:///node_modules/twilio/lib/rest/Twilio.js:261:1) at Api../node_modules/twilio/lib/base/Domain.js.Domain.request (webpack:///node_modules/twilio/lib/base/Domain.js:34:1) at V2010../node_modules/twilio/lib/base/Version.js.Version.request (webpack:///node_modules/twilio/lib/base/Version.js:45:1) at V2010../node_modules/twilio/lib/base/Version.js.Version.page (webpack:///node_modules/twilio/lib/base/Version.js:154:1) at Function.page (webpack:///node_modules/twilio/lib/rest/api/v2010/account/message.js:355:1) at apply (webpack:///node_modules/lodash/lodash.js:488:1) at wrapper (webpack:///node_modules/lodash/lodash.js:5379:1) at fetchNextPage (webpack:///node_modules/twilio/lib/rest/api/v2010/account/message.js:217:1) at Function.each (webpack:///node_modules/twilio/lib/rest/api/v2010/account/message.js:243:1) at Function.list (webpack:///node_modules/twilio/lib/rest/api/v2010/account/message.js:305:1)
Please suggest the solution