Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

373
Views
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 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!