To err is human, to create error handling middleware is divine. This article will explore how to catch and handle errors in Express using Mongoose and then display the errors to the end user using React.
All code used in this article is in this repo.
This diagram shows the modules we’ll discuss in the article. This app is using the MERN stack. The server is running through an Express app, and is connected to a MongoDB database. The frontend is a React app. These are the files we’ll be using for error validation:
Steps described:
As you can see, this article has a few steps. It assumes some familiarity with Express, MongoDB/Mongoose, authentication, React/React router, and React hooks.
#node #mongodb #error-handling #frontend #react