When I send data from frontend to backend via API request I got this error:
Class constructor ObjectId can not be invoked without 'new' in mongoose,
I tried to convert into string and also into int but it didn't work.....
I am new to nodejs too, i am trying to post some questions, even answers that i am not able to find.
Here the problem not from frontend and backend, it is from mongoose schema
when we are converting data to objectId we just need to declare new
.
Solution: new mongoose.Types.ObjectId(Id)
If you find helpful then like the answer so others reach fast.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With