title: How to get JSON data from API using Javascript?
body: <p>I'm trying to get the JSON data from the website <a href="https://api.cryptonator.com/api/ticker/btc-usd" rel="nofollow noreferrer">https://api.cryptonator.com/api/ticker/btc-usd</a></p>
  <p>How would I go about using Javascript to extract the JSON data? Specifically I would want the price field to be outputted.</p>
  <p>For a little context, I'm making a small Crypto project that tracks prices in real time so I would be using it with HTML like so:</p>
  <pre><code>    &lt;h1&gt; Bitcoin (BTC) &lt;/h1&gt;
  
      &lt;p&gt; Price in USD: $&lt;span id=&quot;price&quot;&gt;&lt;/span&gt;
  
      &lt;/p&gt;
      &lt;script&gt;
        const api_url = 'https://api.cryptonator.com/api/ticker/btc-usd';
  
        async function getBTCPrice() {
          const response = await fetch(api_url);
          const data = await response.json();
  
          console.log(data.ticker.price);
  
          const price = data.ticker.price;
  
          document.getElementById('price').textContext = price;
        }
  
        getBTCPrice();
      &lt;/script&gt;
  </code></pre>
  <p>Where the Price in USD (Real-time): $ would update based on the price in the API.</p>
  <p>Any help would be appreciated, thanks!</p>