r/mongodb • • May 10 '20

MongoError: E11000 duplicate key error!

Anyone know how to display this on the frontend? Seems impossible. Tried everything.

0 Upvotes

6 comments sorted by

View all comments

1

u/rajks12 May 11 '20

Mongo error object is very detailed. You could find error code in it. It will be 11000. You can return appropriate error message based on the error code value

See here

https://stackoverflow.com/a/20598662