I am having issues with format of angular app form post. Here is the html code for the form
<form class="col s8 center">
<h4>
{{greeting}}
</h4>
<div class="row">
<div class="input-field col s12">
<input id="email" type="email" class="validate" ng-model="user.email">
<label for="email">Email</label>
</div>
<div class="input-field col s12">
<input id="password" type="password" class="validate" ng-model="user.password">
<label for="password">Password</label>
</div>
</div>
<div class="row">
<div class="col s12">
<input type="submit" class="waves-effect waves-light btn pink" style="width:100%" value="Login" ng-click="login(user)">
</div>
</div>
</form>
here is the angular login function that i am using
$scope.login = function(user) {
console.log(user.email);
$http({
url: baseDomain + 'auth/login/',
method: "POST",
data: user,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).then(function(response) {
$window.localStorage.token = response.data.token;
}, function(response) {
console.log(response);
});
};
Now the function is being called properly but the post data is like
{"password":"d","email":"d@s"}:""
What is the corrct way to do the same and where am i going wrong ?
** Edit **
the post data is taken from firefox dev tool inspector.