Skip to content

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

@jschof1

Description

@jschof1

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions