【发布时间】:2021-05-26 11:06:22
【问题描述】:
我不知道为什么即使数据存在它也不起作用。
查询
$employee = Employee::where('email', request('email'))->first();
if(!$employee)
{
return response()->json(['error' => 'User not found.'], 401);
}
API.php
Route::post('employeelogin', 'EmployeeController@employeeLogin');
邮递员"error": "User not found."出错
【问题讨论】:
-
postman 中如何获取数据?
-
你的
request('email')有错误应该是$request->email -
@KamleshPaul imgur.com/ghRBJpl
-
我猜是邮递员从
x-www-urlencoded标签发送的 -
@KamleshPaul 如果我在 Postman 中以
JSON格式发送数据,它会起作用
标签: php laravel api postman query-builder