Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

198
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda