I have this code and I want to use the coinPrice
variable outside the function, but I can't do it. Can anyone help me out ?
var burl = 'https://fapi.binance.com';
var query = '/fapi/v1/ticker/price?symbol=BNBUSDT';
var url = burl + query
var XMLHttpRequest = require('xhr2');
var xhr = new XMLHttpRequest();
var ourRequest = new XMLHttpRequest();
ourRequest.open('GET', url, true);
ourRequest.onload = function() {
console.log(ourRequest.responseText);
const coinPrice = ourRequest.responseText
console.log(coinPrice)
}
ourRequest.send();