0

I was just trying to display certain data from this url on my website. Therefor I wanted to fetch the data - especially the value which is connected to the "30d"-key (in "EUR").

My approach:

<!DOCTYPE html>
<html lang="en">
<head>
<title>BTC</title>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
</head>

<body>
    <div class="mypanel"></div>

    <script>
    $.getJSON('https://api.bitcoincharts.com/v1/weighted_prices.json', function(data) {
        
        var text = `Date: ${data.EUR.30d}`
                    
        
        $(".mypanel").html(text);
    });
    </script>
    
</body>
</html>

I thought that this would extract the value of the "30d"-key in "EUR" and display it on my website, when I insert the code to the webiste.

Unfortunately it does not display the value and I do not know yet how to update the code periodically.

Scify
  • 1
  • 1
  • Check the browser console, I think this is a [CORS](https://developer.mozilla.org/de/docs/Web/HTTP/CORS) problem. Check also [this answer](https://stackoverflow.com/questions/20035101/why-doesn-t-postman-get-a-no-access-control-allow-origin-header-is-present-on). – Coli Mar 27 '20 at 10:17
  • There is a cors issue. For the updating, wrap it in a setTimeout() function to re-run it after your desired time https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_win_settimeout – Simon Mar 27 '20 at 11:23

0 Answers0