Error: Cannot read properties of undefined (reading 'lang')

Hi every one… can anyone help me solve this? I created a function that makes a query from a database, and then populates the result to a repeater. This error always appear in the debug though details is still successfully populated in the repeater… I’ve been stuck here for weeks. I’m thinking of leaving it there and just go one with next code but I’m worried that this may affect my site performance. Below is my code:

myQuery3
. eq ( “_owner” , wixUsers . currentUser . id )
. contains ( " field title " , “value” )
. descending ( “to” )
. find ()
. then (( results ) => {
if ( results . length > 0 ) {

                    $w ( "#button1" ). show (); 
                    $w ( "#repeater2" ). data  =  results . items ; 
                        $w ( '#repeater2' ). onItemReady (( $item ,  itemData )=>{ 
                            $item ( "#input1" ). value  =  itemData . cn ; 
                            $item ( "#input2" ). value  =  itemData . **from** ; 
                            $item ( "#input3" ). value  =  itemData . to ; 
                            **if**  ( itemData . degreeObtained === "" ) { 
                                $item ( "#ebdegreeObtained" ). collapse (); 
                                }  **else**  { 
                                $item ( "#ebdegreeObtained" ). value  =  itemData . degreeObtained ; 
                                $item ( "#ebdegreeObtained" ). expand (); 
                            } 
                            $item ( "#ebawardsandRecognition" ). value  =  itemData . awardsAndRecognition ; 
                       
                        }) 

Thanks in advance

Hi Juan,

Can you post a screenshot of the error?

About your code,
The $w(“#repeater2”).onItemReady should not be there.
You better place it on the site $w.onReady() function.
When change the repeater data, it should change all the needed values from there.
Adding it in another function might cause problems when u use it more then once.

Kind regards,
Kristof.

Hi sir Kristof!!!

Thank you for your response. Tried to removed the $w(“#repeater2”).onItemReady from the function I created and placed it on $w.onReady() function. asyou suggested but error still appears. I also tried to put all the code I placed in the function I created in the $w.onReady() but still to no avail. Attached is the screenshot of the debug. The details that I wanted to display in the repeater is still displayed though.

I notice that this error only appears when the result of query is >0. Do you think it has something to do with the database? I checked the field type of user input vs. field type of data base and it looks pretty fine to me…

This is giving me headache for weeks. Will this really affect my site performance if I leave it as it is? Coz I’am really thinking to heading to my next code since my function still populate the items that I want to display in the repeater2

Thank you in advance sir Kristoff :sweat_smile:

Oke, now i know a bit more.
The reason you don’t have any problems could be 2 things:

  1. You do not use the collection field “lang”
  2. You have an empty row in your collection.

If you do use the collection field “lang”, check if they all have an image.
Also check if you are having an empty row in your collection.

Kind regards,
Kristof.

@volkaertskristof Ok… I’ll give it a try… Thanks again sir Kristoff… :grin::grin::grin:

Let me know if this whas the problem :wink: and its Kristof with 1 “f” :sweat::rofl:

@volkaertskristof hi sir… Did what you suggested but still the same… I also changed the code in the function from onItemReady to forEachItem still the same…

… But the good thing though is it still populates the data that I want to display in the repeater… I guess I’ll just move on with my next code.

Do you think it will affect my site’s performance? Tried the published site and it works perfectly fine.