How to access nested JSON objects via Ajax?
You need data
twice; one is your variable, one is the outer object in the response. The correct version would be:
console.log(data.data.quotes.USD.price);
var $j = jQuery;(function(getPrice) { $j.ajax({ url: 'https://widgets.coinmarketcap.com/v2/ticker/3012/', type: 'GET', }).then(function(data) { console.log(data.data.quotes.USD.price); });})();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Also note that I removed async: false
(as it's terrible practice) and data: 'data'
was not needed.