I'm new to JS .
so i want to be able to convert currency , especially IDR to USD. and i want to use fixer.io . so here is my code :
function idr_to_usd(){
var url = $.getJSON("http://api.fixer.io/latest?base=IDR&symbols=USD");
var respon = url.responseJSON;
var rates = respon.rates.USD;
return rates;
}
it doesn't work , in inspector it say : filename.js:46 Uncaught TypeError: Cannot read property 'rates' of undefined
but i try the code directly in inspector console and it work. so where did i do wrong ? Thanks