简体   繁体   English

axios 发布请求 - 错误:getaddrinfo ENOTFOUND

[英]axios post requests - Error: getaddrinfo ENOTFOUND

I'm using axios inside a cli node script.我在 cli 节点脚本中使用 axios 。 I've noticed that sometimes inside the console this error will be logged:我注意到有时在控制台内会记录此错误:

Error: getaddrinfo ENOTFOUND www.foobar.com
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:67:26) {
  errno: -3008,
  code: 'ENOTFOUND',

It will be handled by the .catch() function and the next axios request to the same address will continue work and I get 200 status code.它将由.catch() function 处理,下一个 axios 请求将继续工作,我得到 200 状态码。 Is there any reason that cause that a axios.post request can generate that error?是否有任何原因导致axios.post请求会产生该错误?

As @Javapocalypse commented, you should add http:// beginning of your url.正如@Javapocalypse 评论的那样,您应该在 url 的开头添加http://

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM