0

I am having issues performing a simple GET call to microsoft's keys. This call works perfectly in postman but will not work in NodeJS.

Any ideas why?

const http = require('https');

var options = {
    host: 'login.microsoftonline.com',
    path: '/common/discovery/keys'
  };

  callback = function(response) {
    var str = '';
  
    //another chunk of data has been received, so append it to `str`
    response.on('data', function (chunk) {
      str += chunk;
    });
  
    //the whole response has been received, so we just print it out here
    response.on('end', function () {
      console.log(str);
    });
  }
  
  http.request(options, callback).end();
user68288
  • 702
  • 2
  • 6
  • 27
  • I've recently started experiencing this, however, I'm experiencing it using Axios. Did you find a resolution? – BradBeighton Dec 06 '22 at 14:09
  • I wouldn't call it solved but I believe the issue deals with the host file on your pc. I am running in a docker container. Give this link a look: https://stackoverflow.com/questions/23259697/error-getaddrinfo-enotfound-in-nodejs-for-get-call – user68288 Dec 06 '22 at 21:52

0 Answers0