Day 5
Updating the request data to send what Laravel expects
I get a 422 from the /api/register
endpoint when sending this data:
{ "email": "[email protected]", "password": "bbbbbb", "username": "a" }
The response
helpfully tells me
{
"message": "The name field is required. (and 2 more errors)",
"errors": {
"name": ["The name field is required."],
"password": [
"The password field confirmation does not match.",
"The password field must be at least 8 characters."
]
}
}
+1 for developer experience because the data is validated out of the box and clear error messages are provided.
The fix
This required 3 updates to fix:
- Change the
username
param toname
- Add the
password_confirmation
param that Laravel expects and compares against thepassword
param - Update my error message to match the error message that Laravel provides
It’s now creating users!! I confirmed the user was in the database.
Next steps
Next I’ll tackle the login flow.