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

374
Visualizações
Client side Javascript fetch() POST not sending empty objects to server endpoint

I need some help with fetch() POST. The server-side works with Postman, but when I execute a fetch from JavaScript the server endpoint receives an empty object as the req.body.

I have looked at many of the previous questions on this topic with similar symptoms and tried various approaches but I cannot get it to work.

Client-side body:

[
  {"gallery":"1","mode":"assign","node":"South Pubs","image":"00000005.jpg"},
  {"gallery":"1","mode":"assign","node":"South Pubs","image":"00000006.jpg"}
]  

Server side receives empty object.

{}

Server-side Code

const assignPhotos = (req, res) => {
  var gallery
  var mode
  var node
  var photo_name
  console.log(req.body)
  str = JSON.stringify(req.body)
  console.log("str: " + str)
  lgt = str.length
  sp = 1
  segs = []
  let i = 0
  let seg_count = 0
};

Client-side code:

async function postData (url = '', data = {}) {  
const options = {
  method: "POST",
  mode: "no-cors",                  
  cache: "no-cache",               
  headers: {
      "Content-Type": "application/json;charset=utf-8"
    },
  redirect: "follow",               
  referrerPolicy: "no-referrer",    
  body: JSON.stringify(data)
  };
  const response = await  fetch(url, options); 
  const json = await response.json();
      return response.json(); 
};

postData('http://localhost:5030/assigns',matrix);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I found a solution in question: 67710257. But no explanation was given.

about 4 years ago · Juan Pablo Isaza Relatório
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