Closed webdeveloper001 closed 4 years ago
Same as https://github.com/twilio/twilio-node/issues/575
The URL class has been available since Node v6.13.0 (reference). Are you sure you're using Node v12?
I have the same exact issue, with the twilio video create room method
Error:
Technical details: "twilio": "^3.46.0", node version: v13.12.0
Anyone can provide any tips on how to fix this?
Thank ya'll!
After some digging and help, looks like this is related to https://github.com/defunctzombie/node-url/issues/37
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
I think there are significant valid use cases wherein someone might want to run twillio-node on a react frontend. For example, in an electron app where the user is also the owner of the twillio account (or are from the same organisation). This is my use case. It seems that, apart from this URL class issue, nothing else would stop twillio to work on the frontend. Is there any workaround ? How could one get access to the URL class native to node, but in a browser?
You can use the REST HTTP API directly using axios for http requests, and qs.stringify to get the parameters encoded properly:
await(axios.post("https://api.twilio.com/2010-04-01/Accounts/" + sid + "/Messages.json", qs.stringify({
Body: message,
From: from,
To: to
}), {
auth: {
username: sid,
password: token
}
}));
am having the same issue with angular, any one with a satisfactory solution
am having the same issue with angular, any one with a satisfactory solution
Did you see my approach above? It's how you make requests without needing to use the twilio-node library.
You can use the REST HTTP API directly using axios for http requests, and qs.stringify to get the parameters encoded properly:
await(axios.post("https://api.twilio.com/2010-04-01/Accounts/" + sid + "/Messages.json", qs.stringify({ Body: message, From: from, To: to }), { auth: { username: sid, password: token } }));
May you share the whole script so as to easily follow up with your code
May you share the whole script so as to easily follow up with your code
The whole thing is there. message is a string of what you want to send. from is the twilio number you are using. to is the destination number. sid and token are the twilio authentication details. You will need to import axios and import qs:
axios = require('axios') qs = require('qs')
This lets you send SMS via Twilio from a browser. It's live in Uganda right now. ;-)
The challenge am having is that the api recognizes my phone number as invalid even when I use E.164 format On Wed, May 19, 2021 at 10:43 PM Mike McKay @.***> wrote:
May you share the whole script so as to easily follow up with your code
The whole thing is there. message is a string of what you want to send. from is the twilio number you are using. to is the destination number. sid and token are the twilio authentication details. You will need to import axios and import qs:
axios = require('axios') qs = require('qs')
This lets you send SMS via Twilio from a browser. It's live in Uganda right now. ;-)
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/twilio/twilio-node/issues/577#issuecomment-844414742, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALX4NJRBPOQ45LN7JKUPQHLTOQIHRANCNFSM4NNJP7ZQ .
What's the error code from Twilio?
On Wed, May 19, 2021 at 9:47 PM Tumusiime Barnabus @.***> wrote:
The challenge am having is that the api recognizes my phone number as invalid even when I use E.164 format On Wed, May 19, 2021 at 10:43 PM Mike McKay @.***> wrote:
May you share the whole script so as to easily follow up with your code
The whole thing is there. message is a string of what you want to send. from is the twilio number you are using. to is the destination number. sid and token are the twilio authentication details. You will need to import axios and import qs:
axios = require('axios') qs = require('qs')
This lets you send SMS via Twilio from a browser. It's live in Uganda right now. ;-)
— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/twilio/twilio-node/issues/577#issuecomment-844414742 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/ALX4NJRBPOQ45LN7JKUPQHLTOQIHRANCNFSM4NNJP7ZQ
.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/twilio/twilio-node/issues/577#issuecomment-844417211, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC5342JT4XMIFR66JKMKDTOQIUFANCNFSM4NNJP7ZQ .
21211
On Wed, May 19, 2021 at 10:49 PM Mike McKay @.***> wrote:
What's the error code from Twilio?
On Wed, May 19, 2021 at 9:47 PM Tumusiime Barnabus @.***> wrote:
The challenge am having is that the api recognizes my phone number as invalid even when I use E.164 format On Wed, May 19, 2021 at 10:43 PM Mike McKay @.***> wrote:
May you share the whole script so as to easily follow up with your code
The whole thing is there. message is a string of what you want to send. from is the twilio number you are using. to is the destination number. sid and token are the twilio authentication details. You will need to import axios and import qs:
axios = require('axios') qs = require('qs')
This lets you send SMS via Twilio from a browser. It's live in Uganda right now. ;-)
— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/twilio/twilio-node/issues/577#issuecomment-844414742 , or unsubscribe <
https://github.com/notifications/unsubscribe-auth/ALX4NJRBPOQ45LN7JKUPQHLTOQIHRANCNFSM4NNJP7ZQ
.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/twilio/twilio-node/issues/577#issuecomment-844417211 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AAAC5342JT4XMIFR66JKMKDTOQIUFANCNFSM4NNJP7ZQ
.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/twilio/twilio-node/issues/577#issuecomment-844418746, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALX4NJQBSY2LPWP4OPF4QWTTOQI5BANCNFSM4NNJP7ZQ .
Any suggestions?
On Wed, May 19, 2021 at 10:53 PM Tumusiime Barnabus < @.***> wrote:
21211
On Wed, May 19, 2021 at 10:49 PM Mike McKay @.***> wrote:
What's the error code from Twilio?
On Wed, May 19, 2021 at 9:47 PM Tumusiime Barnabus @.***> wrote:
The challenge am having is that the api recognizes my phone number as invalid even when I use E.164 format On Wed, May 19, 2021 at 10:43 PM Mike McKay @.***> wrote:
May you share the whole script so as to easily follow up with your code
The whole thing is there. message is a string of what you want to send. from is the twilio number you are using. to is the destination number. sid and token are the twilio authentication details. You will need to import axios and import qs:
axios = require('axios') qs = require('qs')
This lets you send SMS via Twilio from a browser. It's live in Uganda right now. ;-)
— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/twilio/twilio-node/issues/577#issuecomment-844414742 , or unsubscribe <
https://github.com/notifications/unsubscribe-auth/ALX4NJRBPOQ45LN7JKUPQHLTOQIHRANCNFSM4NNJP7ZQ
.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/twilio/twilio-node/issues/577#issuecomment-844417211>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AAAC5342JT4XMIFR66JKMKDTOQIUFANCNFSM4NNJP7ZQ
.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/twilio/twilio-node/issues/577#issuecomment-844418746, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALX4NJQBSY2LPWP4OPF4QWTTOQI5BANCNFSM4NNJP7ZQ .
I assume you have read this in detail:
https://www.twilio.com/docs/api/errors/21211
(sending/receiving to the same number perhaps?)
Does it work for other numbers? I did find that there are some Ugandan phone numbers that Twilio won't send to, apparently because they are on a spam list, which seemed really odd since we were messaging teachers.
On Wed, May 19, 2021 at 10:01 PM Tumusiime Barnabus < @.***> wrote:
Any suggestions?
On Wed, May 19, 2021 at 10:53 PM Tumusiime Barnabus < @.***> wrote:
21211
On Wed, May 19, 2021 at 10:49 PM Mike McKay @.***> wrote:
What's the error code from Twilio?
On Wed, May 19, 2021 at 9:47 PM Tumusiime Barnabus @.***> wrote:
The challenge am having is that the api recognizes my phone number as invalid even when I use E.164 format On Wed, May 19, 2021 at 10:43 PM Mike McKay @.***> wrote:
May you share the whole script so as to easily follow up with your code
The whole thing is there. message is a string of what you want to send. from is the twilio number you are using. to is the destination number. sid and token are the twilio authentication details. You will need to import axios and import qs:
axios = require('axios') qs = require('qs')
This lets you send SMS via Twilio from a browser. It's live in Uganda right now. ;-)
— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/twilio/twilio-node/issues/577#issuecomment-844414742 , or unsubscribe <
https://github.com/notifications/unsubscribe-auth/ALX4NJRBPOQ45LN7JKUPQHLTOQIHRANCNFSM4NNJP7ZQ
.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/twilio/twilio-node/issues/577#issuecomment-844417211 , or unsubscribe <
https://github.com/notifications/unsubscribe-auth/AAAC5342JT4XMIFR66JKMKDTOQIUFANCNFSM4NNJP7ZQ
.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/twilio/twilio-node/issues/577#issuecomment-844418746>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/ALX4NJQBSY2LPWP4OPF4QWTTOQI5BANCNFSM4NNJP7ZQ
.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/twilio/twilio-node/issues/577#issuecomment-844427418, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC5325GZ7NO46PKIMG3SLTOQKJDANCNFSM4NNJP7ZQ .
@BannyT
am having the same issue with angular, any one with a satisfactory solution
I found an ugly workaround, hope it helps
URL = typeof window !== 'undefined' && window.URL ? window.URL : URL;
Only once, before any usage of any intercept / request or any url dependencies related.
tested with angular 14 SSR, you should lazy load it to prevent it leak to override global namespace URL of nodejs (mention here https://github.com/muaz-khan/RecordRTC/issues/666)
let z;
let moduleTw;
await this.ngZone.run(async () => {
// https://stackoverflow.com/a/58859327/5748537
moduleTw = await import('twilio');
z = (moduleTw as any).default;
});
Issue Summary
I am using latest version of this library 3.44.0. (I see from the npm version log. it's just a day ago!) and having the following error. TypeError: url.URL is not a constructor when I try to send message. the code is copied from doc. https://www.twilio.com/docs/sms/quickstart/node
Steps to Reproduce
Code Snippet
Exception/Log
Technical details: