Implementing Money JS API

Hello,
I am trying to implement the Money.js library into my project to display the pricing section prices in two currencies. Need help writing code for JS conversion to convert from USD to INR.

I am using the Money.js cdn

Currently trying to console log the INR value however getting an ‘Unexpected token’ error.

Any ideas/ Alternatives?

Here’s the code I have added in the before tag section:

<script type="text/javascript">
    // Load exchange rates data via AJAX:
    $.getJSON(
        'https://openexchangerates.org/api/latest.json?app_id=c188cf0daa584e89bf91c7233c7301fd',
        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
                }
            }
        }
    );
    console.log(fx(100).convert.({ from:"USD", to:"INR" }));
</script>

Here is my site Read-Only: (Webflow - Money JS Test)

([how to share your site Read-Only link][2])

https://money-js-test.webflow.io/

Try this:

    // Load exchange rates data via AJAX:
    $.getJSON(
        'https://openexchangerates.org/api/latest.json?app_id=c188cf0daa584e89bf91c7233c7301fd',
        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
                }
            }
        }
    );
    let someVar = fx.convert(100, {from: "USD", to: "INR"});

    console.log(someVar);

Thanks for replying @rileyrichter. I tried the code you sent however I see an “Uncaught fx error” in the console.

Hey @rileyrichter , Just following up to see if you had any ideas to troubleshoot this issue.

Would really appreciate any solutions/ alternatives.

Thanks!

@kevin-morgan - this may not be the cause of your issue but you are getting a too many requests error from the api: