Cannot read property 'x' of undefined ts


#1

Hi, I’m new here. The first, sorry for my english :smiley:

Well… I want to create a JSON object to call an api resource. I get all the vars from 3 forms and bind it to 3 variables.
60a74708e09ebfac4d6a0ece01462012

Here the 3 console.log to each one when i click on “create client”
578384b53770f95084c48c5148654205
abf3a0c450db6e647c8995dbc6b44377

But when i try to create an object i get this error Cannot read property ‘fuente’ of undefined.
I need to create an object like this:

So i try this for example:

But i get this error:

I know that in view i should use: “{{ segmentacion.fuentes?.id }}” because DOM but i don’t know what is the problem here.

Thank you and again, sorry for my bad english.


#2

You create this.post. Then you try to write stuff in this.post.segmentacion.fuente. But this.post.segmentacion doesn’t exist yet, so it tells you exactly that.