最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Axios Error: connect ECONNREFUSED 127.0.0.1:80 - Stack Overflow

programmeradmin3浏览0评论

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:// or https:// at the front of the URL. – Quentin Commented Apr 30, 2020 at 22:15
Add a ment  | 

1 Answer 1

Reset to default 8

You 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);
})
发布评论

评论列表(0)

  1. 暂无评论