Level 88
Well, if you send no body to the form the validation will fail, right? You say that the name, email, .etc are required. If you don't put them in the body the validation fails and it returns a 422. This is expected behavior.
I am using Laravel 6.2 and vuejs 2.5.17, to communicate with a mysql database. When I am able to properly POST request send on the without body, I get error 422 (Unprocessable Entity)
My API Controller:
public function store(Request $request)
{
$this->validate($request, [
'name' => 'required',
'email' => 'required|email|unique:customers',
'phone' => 'required|numeric',
'address' => 'required',
'total' => 'required|numeric'
]);
$customer = new Customer();
$customer->name = $request->name;
$customer->email = $request->email;
$customer->phone = $request->phone;
$customer->address = $request->address;
$customer->total = $request->total;
$customer->save(); //save data
return new CustomerResource($customer); // save and return
}
// And componentsVue.vue:
...... ......Well, if you send no body to the form the validation will fail, right? You say that the name, email, .etc are required. If you don't put them in the body the validation fails and it returns a 422. This is expected behavior.
Please or to participate in this conversation.