I am making an AJAX post to Laravel controller like below.
<script>
let data = {
a: true,
b: false
}
this.axios.post(this.url, data)
.then (result => console.log(result) )
.catch (result => console.log(result) )
</script>
On the backend side in the Laravel 5.6 controller post action method, I am trying to check what values are posted by AJAX call from frontend. And then I log it to laravel log file.
<?php
public function myPostHandler(Request $request) {
$data = $request->all();
\Log::info("Posted data = " . print_r($data, true));
}
?>
In the laravel.log file ... it shows that the values are empty like below -
[a] =>
[b] =>
So my question is how should I send the boolean data to controller so that it is not getting lost? And also like to understand why Laravel is behaving this way and why my boolean values are getting trimmed ? Is it something caused by middleware ?
PS: Below is my routes which does not have any issue:
Route::get('something/{catchall}', [
'uses' => 'myController@index'
])->where('catchall', '(.*)');
Route::post('something/{catchall}', [
'uses' => 'myController@update'
])->where('catchall', '(.*)');