nuxt.js在asyncData或fetch里面请求的接口报错,在mounted里正常
async fetch({ store }) {
await store.dispatch('setSite')
}
报错下面的错误,一打开页面就报这个错误,换个浏览器也是一样
{ Error: getaddrinfo ENOTFOUND 7890 7890:80
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
errno: 'ENOTFOUND',
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: '7890',
host: '7890',
port: 80,
config:
{ url: '/index/siteinfo',
method: 'get',
headers:
{ Accept: 'application/json, text/plain, */*',
connection: 'keep-alive',
pragma: 'no-cache',
'cache-control': 'no-cache',
'sec-ch-ua':
'" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"',
'sec-ch-ua-mobile': '?0',
'upgrade-insecure-requests': '1',
'user-agent':
'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
'sec-fetch-site': 'same-origin',
'sec-fetch-mode': 'navigate',
'sec-fetch-dest': 'document',
'accept-encoding': 'gzip, deflate',
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,co;q=0.7',
cookie:
'Hm_lvt_ef07bef2da496082a7b3f5853c998d64=1632447858,1632616457,1632725914,1632792192',
host: 'localhost:8000' },
baseURL: 'http://localhost:8000/pc',
transformRequest: [ [Function] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 22347,
withCredentials: true,
adapter: [Function: httpAdapter],
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
validateStatus: [Function: validateStatus],
'axios-retry': { retryCount: 3, lastRequestTime: 1632969900119 },
data: undefined },
这样写正常的
mounted() {
this.$store.dispatch('setSite')
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
host 7890是什么鬼