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

202
Views
get id value from req.body.id for new value of object

I have a field with id value in it. It auto created while created a new data. Concatenated with string. I have doing a try, but it gets undefined value.

  1. code:
const { id, nm_acara, tugas, nm_petugas } = req.body;

const result = await prisma.dinas.create({
  data: {
    kd_dinas: `D-${id}`,
    nm_acara,
    tugas,
    nm_petugas,
    rundown: "/texts/" + req.file.filename,
    },
});
  1. result: result
about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Do you sure you sent the id property to the server? or was it just created by the ORM?

about 4 years ago · Santiago Trujillo Report

0

I think your code is correct

But likely id was not sent properly

So, u should check the existence of id firstly

const { id, nm_acara, tugas, nm_petugas } = req.body;

console.log(id) // print the id

If id still undefined => this issue occurs in client side

about 4 years ago · Santiago Trujillo Report

0

make sure are you using the below lines for parsing application/json!?

  app.use(express.json());
  app.use(express.urlencoded({extended:true}));

console.log the req.body for check are you getting id or not.

about 4 years ago · Santiago Trujillo 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!