TypeError: Cannot read properties of undefined (reading 'indexOf')

Wappler Version : Latest
Operating System : Mac
Server Model: NodeJS
Database Type: Postgres
Hosting Type: Docker (local)

Expected behavior

I have a simple repeat, repeating the top10 results from the database as buttons. Works fine.
I then have a onclick event where I click on the button and it adds it to an array, this array then updates local storage for a form submit later.

Actual behavior

The above works fine, but, on load I get two of these errors:

TypeError: Cannot read properties of undefined (reading 'indexOf')
    at dmxFormatter.js:7:3201
    at Array.filter (<anonymous>)
    at n.where (dmxFormatter.js:7:2834)
    at dmxAppConnect.js:7:28375
    at dmxAppConnect.js:7:25666
    at dmx.parse (dmxAppConnect.js:7:25744)
    at n.$updatePropBindings (dmxAppConnect.js:7:35250)
    at n.$update (dmxAppConnect.js:7:34522)
    at dmxAppConnect.js:7:34630
    at Array.forEach (<anonymous>)

And then every single time I click a button in that repeat, I get the same error added to the console, every time. So I just get this endless amount of errors.

I have spent hours trying to debug this, removing things one-by-one, replacing, adding and I just cannot find the root of the problem.

ChatGPT infers it’s to do with the dmxFormatter.js and dmxAppConnect.js files.

Hey @mgaussie,

From what you are saying the repeat works fine and bring the first 10 results successfully…
The problem is that on page load your code is trying to assign values to the array that do not exist.
Do you assign a source to the array?

If that source has not values when page loads it creates all the errors and every time you click the button throughs again an error because a value of the array does not exist

You should better paste your code here to examine…

You superstar @famousmag. I did have items assigned to the array I am using, however due to your feedback here I found an older array that was now redundant and that was causing the errors even though it was not technically in use. As soon as I removed it - these errors have gone away. Thank you - I appreciate the help.

Wappler team - this isn’t a bug but user error so maybe if it can be removed to ‘help’ as it may help someone else.

2 Likes

Glad it worked for you my friend

1 Like