I am making a fetch API call from my js file ,I have a doubt that when i am using Async/await still the code is executing in asynchronous manner.
I have also tried await at differnt place but its doesn't work.
let info
async function weather(){
// API call
let data=await fetch('http://api.openweathermap.org/data/2.5/weather?'+'&lat=20&lon=44'+'&units=metric'+'&APPID='+WEATHER_KEY)
console.log("inside API")
const res= await data.json();
console.log(res)
}
weather()
console.log("last part")
OUTPUT:
last part
inside API
"VALUE OF RES"
WHAT I EXPECT:
inside API
"VALUE OF RES"
last part
Any help will be highly appreciated..
awaithasn't returned a result yet.awaitweather.await weather()the whole things needs to be inside anotherasyncfunction.weather()is asynchronous. Meaning non-blocking, meaningconsole.log("last part")won't wait for it to complete.