Open BustAces opened 1 year ago
To double check that the connection to mongodb is successfully, i added a console log. No errors and connection is successfull, yet.. still same error.
I have same issue. Anyone knows how to create schemas on the MongoDB?
I am getting the same error. How to fix this?
backend@1.0.0 start nodemon server.js
[nodemon] 2.0.18 [nodemon] to restart at any time, enter
rs
[nodemon] watching path(s): . [nodemon] watching extensions: js,mjs,json [nodemon] startingnode server.js
E:\Online-Crash-Gambling-Simulator\backend\server.js:412 io.emit('crash_history', theLoop.previous_crashes) ^TypeError: Cannot read properties of null (reading 'previous_crashes') at loopUpdate (E:\Online-Crash-Gambling-Simulator\backend\server.js:412:40) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Timeout._onTimeout (E:\Online-Crash-Gambling-Simulator\backend\server.js:351:3) [nodemon] app crashed - waiting for file changes before starting...
FIXED I got the game running. I solved the issue this way.
1. At server.js add the following code after the MongoDB connection line:
Save it and run the server. It will now automatically generate the documents. NOTE: The server will crash thats OK!
2. Now, copy the ID of the document and paste it in server.js at GAME_LOOP_ID. 3. Go to /models/game_loop.js and change: _const gameloop = new mongoose.Schema => const crashSchema = new mongoose.Schema _mongoose.model("game_loop", gameloop); => mongoose.model("Crash", crashSchema);
4. In the root folder, create an .evn file with the following line: PASSPORT_SECRET = "YOURPASSWORDHERE"
5. Go back to server.js and delete or comment out the code you added in step 1. 6. Restart the server and enjoy. This is how it worked for me.
Original message: Noticed the other issues claiming the same but without a clear answer still.. App does connect to my mongodb, i can see it in the connections list, however.. schema's arent generated even though the app has permission. Adding the game_loop schema manually also not solves the problem