Giter Site home page Giter Site logo

Comments (5)

LinoleumKnife avatar LinoleumKnife commented on June 22, 2024 1

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.

shelleyp avatar shelleyp commented on June 22, 2024

Thanks, I'll give that a try.

from money.js.

artworkjpm avatar artworkjpm commented on June 22, 2024

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.

LinoleumKnife avatar LinoleumKnife commented on June 22, 2024

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

ofarukcaki avatar ofarukcaki commented on June 22, 2024

I still have the same error

from money.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.