What block creates error: TypeError: Cannot read properties of undefined (reading 'indexOf')

I’m stuck on why this is getting thrown. I get that something isn’t defined; knowing what block indexOf is will help me find what is undefined.

Thanks,
Tim

Based on the information you provided, it would be impossible for us to diagnose the issue.

I’d start by inspecting what script causes the issue and what’s in the script and then correlating it to logic.

@Tim_Jones

Most likely the problem is in one of these blocks, when the variable “undefined” from the example is undefined (For example, you took the value of an object by a non-existent property).
If the problem is in one of the replace blocks, then it can only happen if there is no comparator (Maybe this will make the search easier).

Regards

1 Like

Thanks @viktor.liablin! This is precisely what I was looking for. Much appreciated.

Best,
Tim

@viktor.liablin

If this is my code -

Would “undefined is not an object (evaluating ‘e.indexOf’)” be thrown because the Go To Page block has redirected the user but the code continues to run and then tries to remove something from an object that doesn’t exist on the next page?

Thanks,
Tim

Hello @Tim_Jones!

Yes, this error will be thrown, so if you don’t want this block to execute when the conditions for redirecting to another page are met, it’s better to include it in the “else” statement. It’s also a good practice to validate the data before manipulating it, especially if you’re not sure that it will always be reliable.
For example, you can use an is type of block for that:

Regards,
Alexander