Categories
JavaScript Answers

How to fix Error: getaddrinfo ENOTFOUND in Node.js for get call?

Spread the love

To fix Error: getaddrinfo ENOTFOUND in Node.js for get call, we should make sure the URL is pointing to a valid location.

For instance, we write

const optionsGet = {
  host: "localhost",
  port: 3010,
  path: "/quote/random",
  method: "GET",
};

const reqGet = https.request(optionsGet, (res) => {});

to call https.request with the valid host and path to make a get request to https://localhost:3010/quote/random

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *