Answer the question
In order to leave comments, you need to log in
`
Is it even possible to return a result in an async function?
I have a function:
async function RenderCurrencies() {
const API_KEY = 'ea1ecb2431c7cc30724620c2b4c2fc24'
const response = await fetch(`http://api.exchangeratesapi.io/v1/latest?access_key=${API_KEY}`)
return response
}
let newVar = RenderCurrencies()
Answer the question
In order to leave comments, you need to log in
You have an error, it will be correct like this:
async function RenderCurrencies() {
const API_KEY = 'ea1ecb2431c7cc30724620c2b4c2fc24'
const response = await (await fetch(`http://api.exchangeratesapi.io/v1/latest?access_key=${API_KEY}`)).text();
return response;
}
let newVar = await RenderCurrencies();
console.log(newVar);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question