Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lukegalea16's avatar

API Http Client not working properly

In one Laravel project I have the following method in an API Controller:

$userEmail = $request->input('email');
$userPassword = $request->input('password');
$user = User::where('email', $userEmail)->first();
return response()->json($user, 200);

The API works perfectly fine from Postman, but when I try making a call from another Laravel HTTP Client, the User::where clause is not working i.e. the user is not returned. I also tried entering a hardcoded e-mail address instead of $userEmail but still the User is not found. It's quite odd for the method to work differently?

Ok for some very odd reason it seems that User is being looked up in the Laravel project from where I am making the call - not sure why this is happening however.

0 likes
5 replies
tykus's avatar

Are you getting a 404 status meaning you have used the wrong URL; or a 401 meaning you have (possibly) a CORS issue?

lukegalea16's avatar

Neither, if I return a string like return 'hello', the string is returned. But I noticed that when using models, they are being queried against the database from the project where I am carrying out the request. It is very weird. Both projects are hosted locally, maybe I set up XAMPP incorrectly? DBs are also being accessed separately because I am using them in views etc.

tykus's avatar

Good for you. Aside, there should be no need to cache anything in your development environment; it is unnecessary, and most often a hindrance (like you have found here)

Please or to participate in this conversation.