Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property '_id' of undefined #33

Open
real-zit opened this issue Sep 3, 2021 · 3 comments
Open

TypeError: Cannot read property '_id' of undefined #33

real-zit opened this issue Sep 3, 2021 · 3 comments

Comments

@real-zit
Copy link

real-zit commented Sep 3, 2021

TypeError: Cannot read property '_id' of undefined in global variable id is not found in the helpers editIcon function

@randomartlover
Copy link

TypeError: Cannot read property '_id' of undefined in global variable id is not found in the helpers editIcon function

What view did you have this error?

Ensure you have the middleware in app.js file

app.use((req, res, next)=> { res.locals.user = req.user || null; next() })

Also, ensure all queries to MongoDB is async with await.
I forgot to put await when using async and it gave me the same error you have

@Satya-N
Copy link

Satya-N commented Feb 3, 2022

TypeError: Cannot read property '_id' of undefined in global variable id is not found in the helpers editIcon function

TypeError: Cannot read property '_id' of undefined in global variable id is not found in the helpers editIcon function

What view did you have this error?

Ensure you have the middleware in app.js file

app.use((req, res, next)=> { res.locals.user = req.user || null; next() })

Also, ensure all queries to MongoDB is async with await. I forgot to put await when using async and it gave me the same error you have

the public story view file is showing the error
already used the app.use((req, res, next)=> { res.locals.user = req.user || null; next() }) in app.js file

@yashowardhan01
Copy link

Any solutions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants