csvlint.rb icon indicating copy to clipboard operation
csvlint.rb copied to clipboard

Making POST requests via Node.js returns 'empty' response

Open jschof1 opened this issue 2 years ago • 0 comments

When I make a post request using JavaScript the response returns an empty string. I can only seem to get the correct response via a cUrl request.


var url = "http://csvlint.io/package.json";

var xhr = new XMLHttpRequest();
xhr.open("POST", url);

xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

xhr.onreadystatechange = function () {
  if (xhr.readyState === 4) {
      xhr.responseText
      
  }
};

var data = "urls[]=http://theodi.github.io/hot-drinks/hot-drinks.csv";

xhr.send(data);
let res = xhr.responseText
console.log(res)

jschof1 avatar Jun 15 '22 15:06 jschof1