简体   繁体   中英

User dispatch:phoneformat.js Server-Side in Meteor Application

I am using the dispatch:phoneformat.js package. It works fine on the client side, but when I attempt to use it server side I get the following error: [Error: Object #<Object> has no method 'formatE164']

Looking at the GitHub repo, I believe it should work server-side "out-of-the-box"

I'm simply trying to call Phoneformat.formatE164 from a Meteor method. It works fine if I call it from client side code.

According to the source code on the package from https://github.com/DispatchMe/phoneformat.js/

The package does not support getting formatE164 on the server side. The only server side methods are Phoneformat.configure which allows you to use the phoneformat.getCountryForIp method.

It looks a bit like the package was designed to be this way. You may have to request the author to modify it to be more isomorphic.

I suspect the google.phoneformat.js package its built from doesn't run on the server judging from the use of client side window code in the file. This may be why the method only works on the client side.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM