Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda