Comments (5)
I am assuming you are trying something like: fx.convert(12.99, {from: "GBP", to: "HKD"}); and it is resulting in "fx error"
If you try something simple like: fx(10000); you should get a value back. If you do, then the issue is you probably need to set up the exchange rates: http://openexchangerates.github.io/money.js/#fx.rates
from money.js.
Thanks, I'll give that a try.
from money.js.
I had the same error, so I put the rates in as stated in http://openexchangerates.github.io/money.js/#fx.rates
However, these are old static rates, what I wanted to do was actually update my values with the current currency using the api. I have wired up the api:
$.getJSON(
// NB: using Open Exchange Rates here, but you can use any source!
'http://openexchangerates.org/api/latest.json?app_id=[hidden]', function(data) {
// Check money.js has finished loading:
if (typeof fx !== "undefined" && fx.rates) {
fx.rates = data.rates;
fx.base = data.base;
} else {
// If not, apply to fxSetup global:
var fxSetup = {
rates: data.rates,
base: data.base
}
}
});
Can you tell me if its possible to do this?
from money.js.
@artworkjpm - If I were in your position, I would utilize the default fx.rates on initialization and then update them with this api request you make. This will prevent any fx errors occurring with trying to use the library without setting up the rates, the underlying issue reported here.
The only caveat is that, in between the initialization and the api success, if you are utilizing the library, your values will be inaccurate and you will have to update them after the api success.
There are a dozen ways to get around that issue, but I don't know enough about your environment to comment.
Hope that helps.
from money.js.
I still have the same error
from money.js.
Related Issues (20)
- Very Bad BUG!!!!!!!!!!!!!!!!!!
- Doesn't work in Internet Explorer 8 and 9
- fxSetup doesn't work with browserify
- Request to support with "Meteor JS" (Official)? HOT 2
- Adding the latest rates automatically HOT 1
- v0.2 has not been given a tag.
- Can only use hard-coded rates, not those from openexchangerates
- Be able to get another instance of the module HOT 1
- Consider adding licence HOT 1
- add it to bower
- Additional alternative currencies support HOT 1
- Cannot get it to work on Node.js HOT 1
- This library is how to use in the end, did not understand
- Not working with Webpack
- Alternative for money.js - Cashify HOT 2
- Error in render : Fx error when rendering it as a module
- Add additional rate that cannot be obtained from API HOT 1
- Get current exchange rate function
- Tweet Not working properly (takes longer time )
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from money.js.