apparently I am trying to make a registration system which is failing the local server web-page isn't loading,
my user data is not been sent to MongoDB and also VS Code terminal is throwing out errors at me
VS Code ERROR :
(node:3188) UnhandledPromiseRejectionWarning: MongooseError: Operation `users.insertOne()` buffering timed out after 10000ms
at Timeout.<anonymous> (E:\Projects\Applications\chatter\node-rest-api\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:20)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:3188) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:3188) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
MY CODE GOES HERE :
AUTH.JS
const User = require("../models/User"); // REGISTER router.get("/register", async (req, res) => { const user = await new User ({ username: "john", email: "[email protected]", password: "123456" }) await user.save(); res.send("oK") }); module.exports = router;
INDEX.JS
const application = express(); const mongoose = require("mongoose"); const dotenv = require("dotenv"); const helmet = require("helmet"); const morgan = require("morgan"); const userRoute = require("./routes/users"); const authRoute = require("./routes/auth"); dotenv.config(); mongoose.connect(process.env.MONGO_URL, {useNewUrlParser: true, useUnifiedTopology: true}, () => { console.log("connected to MongoDB"); }); // middleware application.use(express.json()); application.use(helmet()); application.use(morgan("common")); application.use("/api/users", userRoute); application.use("/api/auth", authRoute); application.listen(8800, () => { console.log("backend server has been setup and in running!"); });
I initially in /api/auth after changing my code i needed to change URL to /api/auth/register but it is taking forever to load,
also the following is shown by Developer Tools (Ctrl + Shift + I) ERROR IN CONSOLE