I am not sure wether there is a serious problem or I am doing it wrong. I am using Laravel4 and Angularjs V1.2.5.
My code is simple and looks as follows:
Controller function:
public function userLogin(){
// First we fetch the Request instance
$request = Request::instance();
// Now we can get the content from it
$content = $request->getContent();
print_r($content);
}
Angular code:
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
$scope.userLogin = function(event){
event.preventDefault();
var email = $scope.email;
var password = $scope.password;
var url = $location.absUrl()+'/userLogin/';
var params = {'password': password, 'email': email};
var loginRequest = $http({
method: 'POST',
url: url,
data: params
});
loginRequest.success(function(data){
console.log(data);
});
loginRequest.error(function(data){
console.log(data);
});
};
But the response is always empty. I have tried many ideas but didn't work. The data is sent sucessfully but I am not able to read it on the server.
I tried the default Laravel methods like Input::all()
OR Input:get()
but none of the work.
Any help would be greately appreciated.