Javascript 使用Ext Direct创建Laravel窗体对象
我在前端Ext项目中使用ExtDirect与我的Laravel API进行交互 我在我的Javascript 使用Ext Direct创建Laravel窗体对象,javascript,php,laravel,extjs,ext-direct,Javascript,Php,Laravel,Extjs,Ext Direct,我在前端Ext项目中使用ExtDirect与我的Laravel API进行交互 我在我的AuthController中有一个登录方法,它像这样使用请求对象 public function login(Request $request) { $validator = Validator::make($request->all(), [ 'email' => 'required|string|email|max:255', 'password'=&
AuthController
中有一个登录方法,它像这样使用请求对象
public function login(Request $request)
{
$validator = Validator::make($request->all(), [
'email' => 'required|string|email|max:255',
'password'=> 'required|string|min:6'
]);
if ($validator->fails()) {
return response()->json($validator->errors(), 400);
}
$credentials = $request->only('email', 'password');
try {
if (! $token = JWTAuth::attempt($credentials)) {
return response()->json(['error' => 'Invalid Credentials'], 401);
}
} catch (JWTException $e) {
return response()->json(['error' => 'Could not create token'], 500);
}
return response()->json(compact('token'));
}
然后我的javascript是这样的
var formData = new FormData();
formData.append("email", username);
formData.append("password", password);
Ext.rpc.Auth.login(formData, function(response) {
console.log(response);
});
当我运行代码时,我得到以下错误:
Argument 1 passed to App\Http\Controllers\AuthController::login() must be an instance of Illuminate\Http\Request, instance of stdClass given
如何将formdata对象更改为与Laravel请求对象兼容?
任何帮助都将不胜感激。请您添加整个
登录控制器
?@RossWilson登录控制器不是这里的问题,但我已经添加了它。您是否在控制器顶部添加了此代码<代码>使用\Http\Request代码>