0

I'm trying to write an async function that returns the response from the find ISS API using axios. What's happening is whatever I ty to return winds up as a pending promise. If I try to access the information in the function with console.log that works

 async function apiCall(url)  {
    try {
        const response = await axios.get(url);
        console.log(response.status)
        return response;
    } catch (error) {
        console.error(error);
    }
}
console.log(apiCall("http://api.open-notify.org/iss-now.json"))

and it logs

Promise { <pending> } 200
a.ak
  • 659
  • 2
  • 12
  • 26

0 Answers0