I am trying to set btcPrice
in getJSON method. when I write log outside the value of btcPrice
still 63000. How catch outside getJSON
var btcPrice = 63000
sovBuyPrice = 0.0001
sovBought = 1027
$.getJSON("https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd", function(data){
btcPrice = data["bitcoin"]["usd"];
}).fail(function( dat, textStatus, error ) {
var err = textStatus + ", " + error;
alert(err);
});
console.log(btcPrice);