Bummer! This is just a preview. You need to be signed in with an account to view the entire instruction.
Instruction
Return Validation Error Messages
If the errors
array contains any elements (indicating that one of our validation rules failed) let's return a response with a 400 Bad Request
HTTP status code along with the errors.
-
In
route.js
, add theif
statement shown below to thePOST /api/users
route handler:// Validate that we have a `name` value. if (!user.name) { ... } // Validate ...