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

202
Vistas
JSON Object values set to null when posting from NEXTJS to EXPRESS

I realised a form using NextJs and on the submit button click i would love to save the values to a MongoDb database , so i implemented a function

I am using EXPRESS to run my Backend for your information.

 const validationForm = async (values)=>{
    const result = await fetch("http://localhost:8000/inscription",{
      mode:'no-cors' , 
      method: 'post',
      body: JSON.stringify(values),
      headers : {
        'Content-type':'application/json'
      }
    })
    const body = await result.json()
    console.log(body)

  }

but in my database every field of the JSON Object is set to Null , now that is just part of the problem , the other part is that when i submit the form i get an error directly in the navigator :

Unhandled Runtime Error SyntaxError: Unexpected end of input
const body = await result.json() ^

i have tried removing the await result.json() line of code and i dont get the error no more , but still the values of the JSON Object are set to Null. => values contains ( name,surname,password....etc)

NOTE: I am using the NO-CORS mode because otherwise i get blocked with the cors policy, so if anyone could help with that , it would be much appreciated.

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