Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Getting Error: Network Error at e.exports (createError.js:16) at XMLHttpRequest.g.onerror (xhr.js:117) for API call

I am trying to make an API request by Axios but am getting this error.

Error: Network Error
    at e.exports (createError.js:16)
    at XMLHttpRequest.g.onerror (xhr.js:117)

Here is the code:

    async function getData() {
  await axios
    .get(
      "api.openweathermap.org/data/2.5/weather?q={city name}&appid={api key}"
    )
    .then(function (data) {
      console.log(data);
    })
    .catch(function (err) {
      console.log(err);
    });
}

How can I solve this?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thanks

>Solution :

Try mentioning the right protocol.

"https://api.openweathermap.org/..."

Make sure you’re using the right URI path. Also check your connectivity. The values of err might be worth examining as well.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading