I am already trying to assign a value for a variable by HTTP callback.
But when I try to assign it, the value isn't assigned on the getCurrentRate
scope.
At the end of the html get I need to return the data object to the function that called getCurrentRates
.
function getCurrentRates(baseCoin) {
let data
const uri = 'https://api.exchangeratesapi.io/latest?base=' + baseCoin
https.get(uri, (res) => {
let chuncks
res.on('data', (chunck) => {
chuncks += chunck
})
res.on('end', => {
data = chuncks
})
})
}