Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
Cannot send JSON on Get Request javascript chr2

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);
}

});

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!