I think you have missed this to import on top of your controller-
use Illuminate\Http\Request;
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hey Guys,
I'm having a bit of an issue figuring out how to pass a Request object from my javascript application to my laravel backend.
In my javascript framework i am doing the following;
var formData = new FormData();
formData.append("email", username);
formData.append("password", password);
and then passing the formData to my laravel endpoint.
My authenticate function is just a standard;
public function authenticate(Request $request)
The problem is that everytime i try to run my code, i am getting;
Argument 1 passed to App\Http\Controllers\AuthController::authenticate() must be an instance of Illuminate\Http\Request, instance of stdClass given
Does anyone know how I can solve this?
Please or to participate in this conversation.