I'm quite new to React and I'm trying to get a response from weatherapi.com. However I haven't been very successful. The following is my code snippet:
const api_call = async () => {
const url = 'https://api.weatherapi.com/v1/current.json?key=' + API_KEY + '&q=Singapore'
const request = axios.get(url)
const response = await request
console.log('url - ' + url)
console.log('request - ' + request)
console.log('response - ' + response)
}
useEffect(() => {
api_call()
}, [])
the console log that was printed (i had to redact the API Key) :
url - https://api.weatherapi.com/v1/current.json?key=xxxxxxxxxx&q=Singapore
request - [object Promise]
response - [object Object]
I went to the link next generated, and it did show the data I want in the browser.
My axios version is 0.21.1 if it helps.
Now, I want the response to be printed in the console just so I can make sure that I actually got the response. Did I miss something? Thanks beforehand.