I’ve tried entering my program to findOneByFood function but, it seems to not work as it says there is an error. I have run the program package several times to see if maybe that might be causing the error but, that seems to not work.
Use correct user password from your database. Not password of your Mongo account. Avoid angle brackets.
let uri = must use the same sample.env content and ends with semicolons.
First of all, in the sample.env file, add it correctly a MONGO_URI variable: MONGO_URI=‘VALUE’.
MONGO_URI=‘mongodb+srv://:@-vlas9.mongodb.net/test?retryWrites=true’
Replace with the password for the user.
Avoid all angle brackets.
Instead of test? put your database name followed by?
/home/runner/boilerplate-mongomongoose-2/myApp.js:92
if (error) return console.log(error);
^^
SyntaxError: Unexpected token 'if'
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/runner/boilerplate-mongomongoose-2/server.js:67:16)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
You need to properly indent your code through your myApp.js file because you have at least 3 missing closing } and 1 missing opening {
There were 3 missing } and 1 missing {. You still have issues with your code after fixing these, but the error message that shows indicates your Mongo connection string is missing a database name. Also, I notice you are not use the specified version of mongoose (^5.4.0). The version may or may not cause you problems working through this sections challenges.
NOTE: I still see at least one missing }. If you indent your code properly, it is much easier to see when you are missing { or }. You can optionally use a JS Beautifier that will indent the code for you. You would copy/paste into it and then get the results to paste back into your replit.