Skip to content
Advertisement

Wrong use of CDN (libphonenumber-js) or CDN not working?

I am trying to use the library libphonenumber-js.

JavaScript

In my main.js I tried to write a simple code which is from the docs of libphonenumber-js:

JavaScript

However I get this error. Same thing with other functions from the docs.

JavaScript

In my network tabs I can see that the min.js file is being downloaded. But its functions are not usable for some reason. I tried making a min.js file and using it as well but with not luck.

I also tried many different CDN services which also host this library.

Advertisement

Answer

For anyone wondering:

I found out in the issues page of the repo that you have to use window.libphonenumber or just libphonenumber in front of the function. So

JavaScript

Also in my example turns out that the correct function was parsePhoneNumberFromString

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement