title: Http GET Request from NodeJS to external API with http.get()
body: <p>I am trying to do an HTTP GET request to an external API with NodeJS (using Express), but I am not getting any data back. My code is the nextone:</p>
  
  <pre><code> import * as http from "http";
  
  const options = {
      host: "EXAMPLE.COM",
      path: "/MY/PATH",
      headers: {
          "Content-Type": "application/json",
          "Authorization": "Basic XXXXXXXXXXXXXXXXXX"
      }
  };
  
  const req = http.get(options, function(res) {
  console.log("statusCode: " + res.statusCode);
  
  res.on("data", function (chunk) {
      console.log("BODY: " + chunk);
  });
  
  });
  </code></pre>
  
  <p>But the response I get is: 
     <strong>statusCode : 302</strong>  and <strong>BODY</strong> is empty.</p>
  
  <p>The external API works properly (I have tried doing a http GET Request with INSOMNIA and returns data)</p>
  
  <p>The request I am doing <strong>NEEDS</strong> an Authorization Token</p>
  
  <p>What am I doing wrong? or what can I do to get the data back?</p>
  
  <p>Cheers</p>