My server does not receive the json data that is supposed to get sent across. IS there something I am doing incorrectly. My server gets the get request with no data.
var XMLHttpRequest = require('xhr2'); let getJSON = (url, callback) => {
let xhr = new XMLHttpRequest();
xhr.open('GET', url1, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.responseType = 'json';
xhr.onload = () => {
let status = xhr.status;
if (status == 200) {
callback(null, xhr.response);
} else {
callback(status);
}
};
data = JSON.stringify({"url":"myurl.com"});
xhr.send(data);
};
getJSON('http://localhost:8000', (err, data) => {
if (err != null) {
console.error(err);
} else {
console.log(data);
}
});