So i have this JSON object:
{
"event": [
{
"nombre_organizador": "A",
"celular_organizador_secundario": "1234567891",
"nombre_evento": "Torneo de comer"
}
],
"ticket":[
{
"nombre": "Boleto platino",
"cantidad": null
}
]
}
But i can't figure out how to only acces the event part using this validateSchema code, i am currenly writing it as:
export const validateCreateEvent = async (req, res, next) => {
const { event } = req
const validation = await validateSchema(createEventSchema, event)
if (validation.err) {
res.status(400).json({ msg: validation.err })
console.log(event)
return
}
next()
}
It returns the sql querie error as:
sql: "insert into `eventos` (`event`, `ticket`) values ('[object Object]', '[object Object]')"
And if i write the const as { event } = req.body is says its an invalid object
already solved, all i had to do was delete the square bracket within my JSON lmao