Skip to content

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

Answer

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