I am trying to create a user authentication using vue and laravel, after register button click, I am sending the form data to the create user controller where I have coded in this manner
public function store(Request $request)
{
//
$validator = Validator::make($request->all(), [
'firstname' => 'required',
'lastname' => 'required',
'email' => 'required|email|unique:users',
'password' => 'required|min:8',
'phoneno' => 'required'
]);
if ($validator->fails()){
return response($validator->getMessageBag()->jsonSerialize(), Response::HTTP_UNPROCESSABLE_ENTITY);
}
$firstname = $request->firstname;
$lastname = $request->lastname;
$email = $request->email;
$password = $request->password;
$phoneno = $request->phoneno;
return response($request, Response::HTTP_OK);
}
and from my frontend, i am makking an ajax request using axios, i am sending the form data as:
let formdata = this.user;
axios.post('/api/user', {
data: formdata
}).then((data) => {
console.log(data);
})
.catch((error) => {
console.log(error);
});
But in cases where there are errors, i dont get the json i passed from the
$validator->fails() check i only get to see:

Is there a way i can get the json i passed on error?
dd($request->all());