I am still somewhat new to Angular, but I am trying to send a post login request through an API backend (I am building the front end).
So, the API documentation is like this:
curl "URL" -d'user[email]=some%40email.com&user[password]=password&user[password_confirmation]=password' -X POST \ -H "Accept: application/something" \ -H "Content-Type: application/x-www-form-urlencoded"
This is my form:
<form ng-submit='submit()' class='login-form'>
<a ng-href='#/signup'><span class='md-text'>Signup</span></a>
<span class='md-text'>|</span>
<a><span class='md-text'>Forgotten password?</span></a>
<input class='login-input' type='text' ng-model='username' placeholder=' Username'>
<input class='login-input' type='password' ng-model='password' placeholder=' Password'>
<button type="submit" class="btn btn-primary btn-login" ng-model='submit'>Login</button>
</form>
And this is part of my controller:
$scope.submit=function() {
console.log('Submit');
var reqLogin = {
method: 'POST',
url: 'URL',
headers: {
'Accept': 'application/blah,
'Content-Type': 'application/x-www-form-urlencoded'
}
}
$http(reqLogin).success(function(response) {
console.log(response);
});
}
This may be a silly question, but I know to add the headers in angular, I do so in that JSON object I have above.
How do I add the -d portion to my HTTP request?