Tag: 您的

如何使用Laravel API在AngularJS表单中发送csrf_token()?

我正在尝试构build一个angular度+ laravelrest应用程序。 我可以得到我的数据库的意见。 当我尝试添加新项目。 我得到500 error告诉我不匹配csrf令牌。 我的表单布局是: <form class="form-horizontal" ng-submit="addItem()"> <input type="text" ng-model="itemEntry" placeholder="Type and hit Enter to add item"> </form> 这是我如何尝试添加项目数据库: $scope.addItem = function(CSRF_TOKEN) { $http.post('/shop', { text: $scope.itemEntry, csrf_token: CSRF_TOKEN} ).success(function(data, status) { if(data) { var last = _.last($scope.items); _token = CSRF_TOKEN; $scope.items.push({text: $scope.itemEntry, bought: false, id: (last.id + 1) }); $scope.itemEntry = […]