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

375
Vistas
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 Respuestas
Responde la pregunta

0

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

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