I am trying to get data of currency prices using API, but somehow the data is not showing on the page. In the browser, console works everything fine.
Any help is greatly appreciated. Thanks!
Output:
price: undefined
My code:
<script> $(function (){ var $data = $('#data'); $.ajax({ type: 'GET', dataType: 'json', url: 'https://cors.io/?https://www.freeforexapi.com/api/live?pairs=EURUSD', success: function(data) { console.log(data); $.each(data, function([i, price) { $data.append('<li>price: '+ price.rate + '</li>'); }); } }); }); </script> <ul id="data"></ul>
price.EURUSD.rate. Or loop overdata.rates. Check the returned JSON.