0
const axios = require('axios');
const exchangeRate;
axios.get('https://kurs.resenje.org/api/v1/currencies/eur/rates/today').then(function(response){
    exchangeRate = response.data;
})

function one(){
 console.log(exchangeRate);
}

I have code like this. This obviously wont work, but I hope that you get the idea. I tried many solutions online, non of which work. I tried with async await but I always got Promise returned instead of JSON.

1 Answers1

-1

Does this work?

async function run() {
  const url = 'https://kurs.resenje.org/api/v1/currencies/eur/rates/today'
  const response = await axios.get(url)
  const exchangeRate = response.data
}
run()
twharmon
  • 4,153
  • 5
  • 22
  • 48