I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
I’m not sure I understand, are you expecting reviews to become a global variable by not declaring it? Because I don’t believe that works (it gets executed in strict mode inside a class as far as I know).
Well according to the error reviews is undefined so you must not be getting back what you expect from conn.db (or you didn’t invoke injectDB before addReview).
Based on the code you have posted I would have a hard time knowing what the issue might be though. You are using code we can’t see and we can’t see how you are using the code you did post (we pretty much just have the definition, not the usage).
Thank you so much @lasjorg , I am really amazed as this is my first experience with this forum.
Issue was :
i didn’t invoke injectDB before addReview
by adding below line in index.js
await ReviewsDAO.injectDB(client)
resolved the issue
I am so glad that FreeCodeCamp has provided this platform for people in need.
LOVE & RESPECT
I didn’t watch the video but the call to injectDB is in the source code on GitHub.
But there are some comments on the video which suggest he didn’t show it. But as I said, I didn’t watch the video so I don’t know.
Edit: Not sure how we handle corrections to YT videos. But if you are absolutely sure that part is missing from the video, maybe an issue should be opened on Github.
I don’t really know much about YT but I do believe you can add text to videos after they have been uploaded. So a simple pause with some text at the appropriate time might be all that is needed.