I want to store console.log output in a variable. Can anyone help me with that how can I do that ?

var burl = ‘https://fapi.binance.com’;
price = “BNBUSDT”
var query = /fapi/v1/ticker/price?symbol=${price};
var url = burl + query
var XMLHttpRequest = require(‘xhr2’);
var xhr = new XMLHttpRequest();
var ourRequest = new XMLHttpRequest();
ourRequest.open(‘GET’, url, true); ourRequest.onload = function () {
const coinPrice = ourRequest.responseText

I think this question has already being discussed in Telegram channel, but basically programming questions should be asked in another group (upon your own search). Sorry for this, but here we focus on the API usage itself.