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

162
Views
Post request inside on react app not reaching back end ( Uncaught (in promise) SyntaxError: Unexpected end of JSON input)
export function getOneSite(body){
    try {
        console.log("getonesite invoked")
    console.log(body)

    return fetch('http://localhost:3001/oneSite',
     {
        method: 'POST',
        headers: {"Content-Type": "application/json"},
        body: JSON.stringify({body}),
        
    })
    .then(data => data.json())
    } catch (error) {
        console.log(error)
    }
    
    
}

this is the funciton im using to make a post request. the swame kind of request works fine in post man but when i try here it give me

Uncaught (in promise) SyntaxError: Unexpected end of JSON input at services.js:12:1

which points towards the request option object but I cant seem to find what about it is wrong.

here is my api end point

app.post('/oneSite', async (req, res)=> {
    console.log(req.body)
    const data = await getOnesite(req.body)

    res.send(data)
})

and here is the mongoose function behind that

async function getOnesite(body) {
    const siteCardData = await siteCardModel.find({_id: body._id}, {_id:0, __v:0}).populate('outages', {'_id':0, '__v':0})
    console.log('getonesite invoked')
    console.log(body)
    console.log(siteCardData[0])
    return siteCardData[0]
}
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!