Hello i am new in nodejs i have this error when i run my app "Error: connect ECONNREFUSED 127.0.0.1:80 " here is my code
const axios = require('axios')
const url = 'api.openweathermap/data/2.5/weather?q=London,uk&appid=4dd23b28fb57078c0d5ec9c653e203b2'
axios.get(url)
.then((response) =>{
console.log(response)
})
.catch(function (error) {
console.log(error);
})
Hello i am new in nodejs i have this error when i run my app "Error: connect ECONNREFUSED 127.0.0.1:80 " here is my code
const axios = require('axios')
const url = 'api.openweathermap/data/2.5/weather?q=London,uk&appid=4dd23b28fb57078c0d5ec9c653e203b2'
axios.get(url)
.then((response) =>{
console.log(response)
})
.catch(function (error) {
console.log(error);
})
Thank you in advance
Share Improve this question asked Apr 30, 2020 at 19:04 chloychloy 211 gold badge1 silver badge3 bronze badges 2-
try use
base_url
see this github./axios/axios#request-config – Alaa Aqeel Commented Apr 30, 2020 at 19:27 -
3
Typo: You forgot the
http://
orhttps://
at the front of the URL. – Quentin Commented Apr 30, 2020 at 22:15
1 Answer
Reset to default 8You have used a URL without any scheme, that's why axios treating this URL on your localhost that is 127.0.0.1:80. just add http:// or https:// before the url.
const axios = require('axios')
const url = 'https://api.openweathermap/data/2.5/weatherq=London,uk&appid=4dd23b28fb57078c0d5ec9c653e203b2'
axios.get(url)
.then((response) =>{
console.log(response)
})
.catch(function (error) {
console.log(error);
})