Error: getaddrinfo ENOTFOUND in nodejs for get call

后端 未结 10 698
离开以前
离开以前 2020-11-30 00:24

I am running a web server on node the code for which is given below

var restify = require(\'restify\');

var server = restify.createServer();

var quotes = [         


        
10条回答
  •  有刺的猬
    2020-11-30 00:48

    Struggling for hours, couldn't afford for more.

    The solution that worked for me in less than 3 minutes was:

    npm install axios
    

    Code ended up even shorter:

    const url = `${this.env.someMicroservice.address}/v1/my-end-point`;
    
    const { data } = await axios.get(url, {
      auth: {
        username: this.env.auth.user,
        password: this.env.auth.pass
      }
    });
    
    return data;
    

提交回复
热议问题