0👍
The problem like N. Djokic said, was mainly because of validation in my calendar.
I was validating wrong name field when there was no request name set in post axios.post('/user/setdate', this.selectedMonth)
$this->validate($request, [
'selectedMonth' => 'required|string',
]);
I’ve updated submit method in vue with a name for the field:
submit() {
let self = this;
self.errors = {};
axios.post('/user/setdate', {date: this.selectedMonth}).then(response => {
console.log(response.data);
alert('Guardado!');
}).catch(error => {
if (error.response.status === 422) {
self.errors = error.response.data.errors || {};
}
});
},
and now I can get and validate in my controller:
public function setDate(Request $request) {
$this->validate($request, [
'date' => 'required|string',
]);
/*
Add mail functionality here.
*/
return response()->json($request->input('date'), 200);
}
Source:stackexchange.com