Skip to content
Advertisement

TypeError: can’t access property “indexOf”, n is undefined

I want to get a doc from firebase on page render, which I do get first(following a button), but after I refresh the page I get this error:

JavaScript

My code is:

when it works fine I go to the page clicking this div:

JavaScript

but now if I refresh, i get the above error. Rest of the code here:

fbconfig.js:

I export the db const

JavaScript

dynamic [id] route component:

JavaScript

Advertisement

Answer

It still gave me an error, but I just redirected the user back to the homepage if n is undefined so it won’t give me this error again. I had no better idea than this.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement