title: How to extract price using javascript from coingecko API in a nested array
body: <p>I've had success gathering price from cryptocompare.com as below:</p>
  
  <pre><code>https://min-api.cryptocompare.com/data/price?fsym=GRIN&amp;tsyms=USD
  </code></pre>
  
  <p>returns:</p>
  
  <pre><code>{“USD”:0.996}
  </code></pre>
  
  <p>Notice how the USD price is not nested.</p>
  
  <p>When trying to use coingecko's API, the price is nested. For example:</p>
  
  <pre><code>https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&amp;vs_currencies=usd
  </code></pre>
  
  <p>returns:</p>
  
  <pre><code>{"bitcoin":{"usd":7238.46}}
  </code></pre>
  
  <p>My problem is that I can't figure out how to alter the javascript to locate the price.</p>
  
  <p>The pertinent code is below:</p>
  
  <pre><code>$.getJSON("https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&amp;vs_currencies=usd", function(data){
      $("#BTCPrice").text(data["usd"].toFixed(2));
  }).fail(function( dat, textStatus, error ) {
      var err = textStatus + ", " + error;
      alert(err);
  });
  </code></pre>
  
  <p>This code would work for the non-nested data, but not the nested. I'm sure it's a matter of adding something like </p>
  
  <pre><code>$(#BTCPrice").text(data["bitcoin":"usd"].toFixed)2));
  </code></pre>
  
  <p>But I just can't get the syntax right.</p>