I've query like this const result = await Form.findOne({ _id: req.params.id });
And here is the result of my query:
{ _id: 5a8ea110d7371b7e5040d5c9,
_user: 5a5c277f8d82ba3644b971c2,
formDate: 2018-02-22T10:53:04.579Z,
formElement:
{ formName: 'Vanilla Form',
pixel: '23423325',
fieldRows: [ [Object], [Object] ] },
formStyle:
{ globalColor: [ [Object], [Object], [Object] ],
elementSizing: 'medium',
elementStyle: 'radius',
fontFace: 'Open Sans',
fontSize: { label: '15', button: '15' } },
__v: 0,
status: true }
I'm trying to get pixel like this console.log(result.formElement.pixel)
But, when i trying to get the value of pixel, it return undefined
.
What's wrong?
Update
Here is my code:
app.get("/view/:id", async (req, res) => {
const result = await Form.findOne({ _id: req.params.id });
console.log(result);
console.log(result.formDate); //return 2018-02-22T10:53:04.579Z,
console.log(result.formElement.pixel) //return undefined
// res.render("form", {
// result
// });
});
I've try to edit my code without using async instead using Promise, but it also return undefined