Are you getting a 404 status meaning you have used the wrong URL; or a 401 meaning you have (possibly) a CORS issue?
Nov 12, 2020
5
Level 2
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.
Please or to participate in this conversation.