Cannot read propertizs of null (reading 'nom')

1
2


Hello, thanks for your help on this thread.
Here is my problem,

I imported from my database the core table which lists the ingredients of my recipe.
I would like to have access to the name of my ingredients

I can read the name of cid.nom and cid2.nom but for cid 5,6,7 some recipe have nothing.
So vue gave me this error, he can’t display nothing.

You can try to use core.cid5?.nom instead. That will give you null if the cid5 property doesn’t exist.

Also, you can try to consider redesigning your database. Having numbered columns like that is usually not a good idea. You can for example store the ingredients in a relational table, or in worst case as a JSON array in a field in the recipes table.

1 Like

Thanks for your response ! :grin:
It’s work, I start my project with django with webpack loader i use an mysql database.
I will surely redesign my database rapidly with mongodb i think.

For that type of data, using a relational database, like MySQL, probably makes most sense. MongoDB is designed to be scalable, but not suitable to store data that is very important for your solution to work, so I would stick to using a relational database for storing recipes.

But you need to decide which tradeoff that is most important to your solution.

1 Like

This community rocks :fire:
Thanks for your advice :grinning: