php - Laravel 5 AngularJS POST Not Working (TokenMismatchException) -


i'm developing website laravel 5 , use angularjs

here code

$scope.save = function(modalstate, id) {     var url = api_url + "tools";      if (modalstate === 'edit'){         url += "/" + id;     }      $http({         method: 'post',         url: url,         data: $.param($scope.tools),         headers: {'content-type': 'application/x-www-form-urlencoded'}     }).success(function(response) {         console.log(response);         location.reload();     }).error(function(response) {         console.log(response);         alert(response);         alert('error');     }); } 

it show error alert. log, of errors include tokenmismatchexception , verifycsrftoken. seems there problem csrf token.

my angularjs file on different directory view (blade). i've done including hidden input on view file.

<input id="_token" name="_token" type="hidden" value="{{ csrf_token() }}" ng-model="tools._token"> 

but got same error. how fix error?

update:

php version: 7.0.2, laravel: 5.1.27

laravel log file

#1 c:\xampp\htdocs\myweb\bootstrap\cache\compiled.php(9584): call_user_func_array(array, array) #2 c:\xampp\htdocs\myweb\bootstrap\cache\compiled.php(12952): illuminate\pipeline\pipeline->illuminate\pipeline\{closure}(object(illuminate\http\request)) #3 [internal function]: illuminate\view\middleware\shareerrorsfromsession->handle(object(illuminate\http\request), object(closure)) #4 c:\xampp\htdocs\myweb\bootstrap\cache\compiled.php(9584): call_user_func_array(array, array) #5 c:\xampp\htdocs\myweb\bootstrap\cache\compiled.php(11549): illuminate\pipeline\pipeline->illuminate\pipeline\{closure}(object(illuminate\http\request)) #6 [internal function]: illuminate\session\middleware\startsession->handle(object(illuminate\http\request), object(closure)) #7 c:\xampp\htdocs\myweb\bootstrap\cache\compiled.php(9584): call_user_func_array(array, array) #8 c:\xampp\htdocs\myweb\bootstrap\cache\compiled.php(12689): illuminate\pipeline\pipeline->illuminate\pipeline\{closure}(object(illuminate\http\request)) #9 [internal function]: illuminate\cookie\middleware\addqueuedcookiestoresponse->handle(object(illuminate\http\request), object(closure)) #10 c:\xampp\htdocs\myweb\bootstrap\cache\compiled.php(9584): call_user_func_array(array, array) #11 c:\xampp\htdocs\myweb\bootstrap\cache\compiled.php(12626): illuminate\pipeline\pipeline-  >illuminate\pipeline\{closure}(object(illuminate\http\request)) #12 [internal function]: illuminate\cookie\middleware\encryptcookies->handle(object(illuminate\http\request), object(closure)) #13 c:\xampp\htdocs\myweb\bootstrap\cache\compiled.php(9584): call_user_func_array(array, array) #14 c:\xampp\htdocs\myweb\bootstrap\cache\compiled.php(2982): illuminate\pipeline\pipeline->illuminate\pipeline\{closure}(object(illuminate\http\request)) #15 [internal function]: illuminate\foundation\http\middleware\checkformaintenancemode->handle(object(illuminate\http\request), object(closure)) #16 c:\xampp\htdocs\myweb\bootstrap\cache\compiled.php(9584): call_user_func_array(array, array) #17 [internal function]: illuminate\pipeline\pipeline->illuminate\pipeline\{closure}(object(illuminate\http\request)) #18 c:\xampp\htdocs\myweb\bootstrap\cache\compiled.php(9574): call_user_func(object(closure), object(illuminate\http\request)) #19 c:\xampp\htdocs\myweb\bootstrap\cache\compiled.php(2254): illuminate\pipeline\pipeline->then(object(closure)) #20 c:\xampp\htdocs\myweb\bootstrap\cache\compiled.php(2237): illuminate\foundation\http\kernel->sendrequestthroughrouter(object(illuminate\http\request)) #21 c:\xampp\htdocs\myweb\public\index.php(53): illuminate\foundation\http\kernel->handle(object(illuminate\http\request)) #22 c:\xampp\htdocs\myweb\server.php(21): require_once('c:\\xampp\\htdocs...') #23 {main}   


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

json - Gson().fromJson(jsonResult, Myobject.class) return values in 0's -