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

No matter what, always ends in error #17

Open
shelleyp opened this issue Aug 12, 2014 · 5 comments
Open

No matter what, always ends in error #17

shelleyp opened this issue Aug 12, 2014 · 5 comments

Comments

@shelleyp
Copy link

Trying various functions, they all return an error. Tried in client, and in a Node app. Error only says "fx error".

@LinoleumKnife
Copy link

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

@shelleyp
Copy link
Author

Thanks, I'll give that a try.

@artworkjpm
Copy link

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?

@LinoleumKnife
Copy link

@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.

@ofarukcaki
Copy link

I still have the same error

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

4 participants