0
我想用Angular进行登录,但只要我提交表单,我在控制台POST http://localhost/angulav/public/auth 500(内部服务器错误)。角路由错误 - POST http http:// localhost/angulav/public/auth 500(内部服务器错误)
这是我的路线
Route::any('/', function() {
return view('layout.master');
})->where('path', '.+');
Route::post('/auth', '[email protected]');
这是我的UserController中,JS
angular.module('myApp').controller('userController', ['$scope', '$http', function($scope, $http){
angular.extend($scope, {
doLogin: function(loginForm) {
$http({
headers: {'Content-Type': 'application/json'},
url: 'auth',
method: "POST",
data: {
username: $scope.login.username,
password: $scope.login.password
}
}).success(function(response){
console.log(response);
});
}
});
这是我的HTML
<form class="" ng-submit="doLogin(loginForm)">
<div class="form-group">
<label for="username">Username:</label>
<input id="username" class="form-control" ng-model="login.username" type="text" name="username" placeholder="Enter username">
</div>
<div class="form-group">
<label for="password">Password:</label>
<input id="password" class="form-control" ng-model="login.password" type="password" name="password" placeholder="Enter username">
</div>
<div class="form-group">
<input class="btn btn-primary pull-right" id="username" type="submit" value="Submit">
</div>
</form>
这是我usercontroller.php
public function login(Request $request)
{
$user_data = [
'username' => $request->input('username'),
'password' => $request->password('password')
];
if (Auth::attempt($user_data)) {
return response(Auth::user(), 201);
} else {
return response('username and password do not match', 403);
}
}
你有没有试穿邮差? –
@PareshGami:请问邮差是什么? – nana
邮差是从哪里可以测试你的API,因为开始发展的工具。只需在谷歌邮递员搜索铬 –