Level 53
@russellwwest are you setting Content-Type: application/json header?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hey, I'm having an issue where I am using fetch within a Vue app to call my Laravel API. However, my request object in Laravel is empty:
vue api call:
const requestOptions = {
method: 'POST',
headers: requestHeader(false),
/* eslint-disable-next-line */
body: JSON.stringify({ "email": '[email protected]', "password": 'password' })
}
return fetch(`${baseUrl}/auth/authenticate`, requestOptions)
Laravel Controller:
public function authenticate(Request $request) : JsonResponse
{
return response()->json(['message' => $request], 422);
}
The $request object is empty.
if I do this. then I see the data:
$data = json_decode($request->getContent(), true);
What am I doing wrong with the fetch api? It worked fine with axios Thanks,
Please or to participate in this conversation.