I'm new in node environnement and i want to handle undefined error when i access a children of an undefined object.
Like in this exemple :
console.log(req.body.data.colonne)
if req.body is undefined js throw an error.
If it's a GET method req.body is undefined and req.body.data.colonne so.
i know i can do
if (typeof req.body !== "undefined" and typeof req.body.data !=="undefined" and typeof req.body.colonne !== "undefined")
or successive try block or .hasProperty ...
But can i test if req.body.data.colonne exist even if req.body is undefined without an error ?
Thank !
I found this elegant solution
let column = req.body.data.column || ["*"]