csvlint.rb
csvlint.rb copied to clipboard
Making POST requests via Node.js returns 'empty' response
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)