Начал работу с библиотекой 'node-vk-bot-api'. Ошибка возникает на моменте вызова метода getCbr() - он возвращает мне undefined, хотя в методе я возвращаю float-переменную. Спасибо. Буду рад любому Вашему совету.
Код:
async function getCbr() {
try {
await fetch('https://www.cbr-xml-daily.ru/daily_json.js')
.then(response => response.json())
.then((data) => {
let currency = data['Valute']['USD']['Value'];
console.log(currency);
return currency;
});
} catch (e) {
console.log(`getCbr error: ${e}`);
}
}
bot.on(async(ctx) => {
let cbr = await getCbr();
});