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: (https://preview.webflow.com/preview/money-js-test?utm_medium=preview_link&utm_source=designer&utm_content=money-js-test&preview=bdfd8f85a72275faf76b45f1da120108&workflow=preview)
([how to share your site Read-Only link][2])