это потому, что const response = getJson()
выполняет свой код перед запуском getJson
, потому что он асинхронный c и ответ не приходит к этому экземпляру при его выполнении.
# This code runs and executes some point in future when response arrives
const getJson = async ()=>{
const response = await axios.get(url);
//Here i can see the json normally
console.log(response.data)
return response.data
}
# This code runs and executes immediately which doesn't have response yet
const response = getJson()