Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the latest rates automatically #21

Open
artworkjpm opened this issue May 29, 2015 · 1 comment
Open

Adding the latest rates automatically #21

artworkjpm opened this issue May 29, 2015 · 1 comment

Comments

@artworkjpm
Copy link

I can only get this to work if I put the rates in manually:
fx.rates = {
"EUR" : 0.745101, // eg. 1 USD === 0.745101 EUR
"GBP" : 0.647710, // etc...
"HKD" : 7.781919,
"USD" : 1, // always include the base rate (1:1)
/* etc */
}
What I really want is the API to auto update with the latest currency rates.

I wired up the json request:
$.getJSON(
// NB: using Open Exchange Rates here, but you can use any source!
'http://openexchangerates.org/api/latest.json?app_id=[I hid this]', 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
}
}
});

But it doesn't with latest currencies. Any ideas?

@fmartingr
Copy link

Can you specify the error that show up in your console?

I implemented moneyjs yesterday getting the rates from a json data source without problems, maybe your scripts are placed in incorrect order or you're not wrapping the getJSON call in a document ready event?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants