title: How to set multiple HTTP headers in JavaScript get () method
body: <p>I have been searching the total Internet from around a week and finally decided to post here. I want to send an HTTP get request to an API with two headers for authentication. These are custom headers and need to be sent at once.</p>
  
  <p>I have tried the following code but it never gives me success. The API returns a JSON file which will have parameters like "title", "description". The URL and headers work fine, when I tried it using hurl.it.</p>
  
  <p>This is the code. Please suggest some answer to solve this problem. And one more thing is, I want to do it using JavaScript only, no jQuery, AJAX, or AngularJS.</p>
  
  <pre><code>var xmlhttp = new XMLHttpRequest();
  var url = "https://affiliate-  api.flipkart.net/affiliate/offers/v1/dotd/json";
  
  xmlhttp.onreadystatechange = function() {
      if(xmlhttp.readyState == 4 &amp;&amp;xmlhttp.status==200) {
          var myArr = JSON.parse(xmlhttp.responseText);
  
          function display(arr) {
              var i;
              var out = " ";    
              for(i = 0; i &lt; arr.length;i++) {  
                  out += "&lt;p&gt;title:" + arr.dotd[i].title + "&lt;br&gt;description:" + arr.dotd[i].description + "&lt;br&gt;&lt;/p&gt;"; 
              }
              document.getElementById("p1").innerHTML = out;
          } 
      }
      else {
          alert(xmlhttp.status);
      }
  };
  
  xmlhttp.open("GET", url, true);
  xmlhttp.setRequestHeader("Fk-Affiliate-  Token","xxxxxxxxxxxxxxxxx");
  xmlhttp.setRequestHeader("Fk-Affiliate-Id","xxxxxxxxx");
  xmlhttp.send();  
  </code></pre>