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

279
Views
react.js SyntaxError: Unexpected end of JSON input

I have a node js express api and a react js frontend. I send data using Json.stringify() the erorr below is thrown, the app works as expected but anyways I want to clear this out.

The request

const rawResponse = await fetch('http://localhost:8080/data/report/', {
                method: 'POST',
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({
                    desc: description,
                    data: measurement,
                })
            })
            const response = await rawResponse.json();
            console.log(response);

The end point

app.post('/data/report', (req, res) => {
    console.log("[POST] /data/report/")
    console.log(req.body)
    reports.push(...[].concat(req.body))
    res.set('Access-Control-Allow-Origin', '*');
    res.set('Access-Control-Allow-Credentials', true);
    res.set({
        "Content-Type": "application/json",
        "Access-Control-Allow-Origin": "*",
    });
    res.status(201)
    res.send()
})

The error

VM1024:1 Uncaught (in promise) SyntaxError: Unexpected end of JSON input
    at dispatcher.js:28
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!