0

First of all I'm extremely sorry but i can't figure out what the title should be, I'm trying to send data to MongoDB Database but for some reason, I keep getting 304 status code, I tried searching it on the internet but I couldn't find a solution, and was hard for me to understand, can you guys please help me?

Here's the data I'm trying to send to DB

  const router = require("express").Router();
  const User = require("../models/User");



 router.get("/register", async (req,res) => {
 const user = await new User ({
 username:"username",
  email:"User@email.com",
  password:"123456"
  })
 await user.save();
 res.send("okk!");

});


module.exports = router;

// MongooseError: Operation users.insertOne() buffering timed out after 10000ms at Timeout. node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:151:23) at listOnTimeout (node:internal/timers:557:17) at processTimers (node:internal/timers:500:7)

eenu
  • 1

1 Answers1

0

If ang other operation to Mongoose doesn't work too, I guess your Mongoose connection part has problem. Did you check your connection option(URL), or MongoDB connectivity itself? Try same operation on MongoShell, or Compass, etc.

  • And, by the way, if you intended to service "Sign up" API, I think it is better to use HTTP method "POST", not "GET" because of security problems. See https://stackoverflow.com/questions/66874983/login-and-register-requests-in-apis – pcjs156 Jul 27 '22 at 23:08
  • Last, If the connectivity is not a core reason for this problem(means you can receive 304 status code always, no matter of Mongoose), It may be caused by Caching. – pcjs156 Jul 27 '22 at 23:17
  • See https://blog.airbrake.io/blog/http-errors/304-not-modified – pcjs156 Jul 27 '22 at 23:33
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/32351548) – Abdulla Nilam Aug 02 '22 at 05:52