0

Hi,

I have a problem inserting data in mongodb, I have the data dynamically like in your video, it worked first but now its not working. It shows me this error:

Server Error

MongoNotConnectedError: Client must be connected before running operations

This error happened while generating the page. Any console logs will be displayed in the terminal window.

Source

pages\api\seed.js (7:2) @ async handler

   5 | const handler = async (req, res) => {
   6 | await dbConnect();
>  7 | await User.deleteMany();
     |  ^
   8 | await User.insertMany(data.users);
   9 | res.send({ message: 'seeded successfully' });
  10 | };
Kate Asked question May 5, 2023