i am a newbie to laravel and laravel 5 and so ar i am having such a hard time, it's just problem after problem, my current issues is this, i am using angular js on my frontend, so i already have client side validation working and implemented, now when i send my form via $http.post the form is also validated on the server, if there are validation errors it returns the whole page in the response but what i want is only the errors returned as json, i am currently trying my hands on user registration not a custom one but the one that already comes with laravel 5.
this is my register.js:
(function() {
angular.module('vendor').controller('RegisterController', ['$http', '$scope', function($http, $scope) {
$scope.d = {};
$scope.register = function() {
$http.post(
'/auth/register',
{
_token: $scope.d._token,
email: $scope.d.email,
password: $scope.d.password,
password_confirmation: $scope.d.password_confirmation
},
{
'X-Requested-With': 'XMLHttpRequest'
}
).success(function(data) {
// get errors here
});
};
}]);
}) ();
You are going to want to capture and log the errors like so:
$http.post(
'/auth/register',
{
_token: $scope.d._token,
email: $scope.d.email,
password: $scope.d.password,
password_confirmation: $scope.d.password_confirmation
},
{
'X-Requested-With': 'XMLHttpRequest'
}
).success(function(data) {
// successs
}).error(function(error) {
// error
console.log(error);
});