Show your /time route please.
Why using fetch ? What is your front environment ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
my laravel code want to get data from frontend fetch api.
// javascript
var data = new FormData()
data.append('count', count )
data.append('timestamp', timestamp)
console.log(data);
fetch('/time', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': csrf_token
},
body: data,
})
.then((response) => {
return response.json();
})
.then((data) => {
})
.catch((error) => {
console.error('Error:', error);
});
// laravel Controller
function time( Request $request ){
dd($request->all());
}
But dd returns []
how can I get data from fetch FormData ?
Please or to participate in this conversation.