HTTP request in undefine sending angular values

advertisements

** It turns out that the problem was at the server **

I'm trying to excute HTTP post request (from my angular client) to my server (node express). The server recive the request but the data is undefined.
Already tried to make this req by postman and it worked perfect there.

var req = {
method: 'POST',
url: _url +'/login',
headers: {
  'Content-Type': 'application/x-www-form-urlencoded'
},
data: { user: 'someUser', password :'somePass' }
}

$http(req)
    .then(function success(res){
        ...
    }, function error(res){
        ...
});


You are sending JSON data and sending the header of x-www-form-urlencoded.

Change the content type to "application/json"

Like:

headers: {
  'Content-Type': 'application/json'
}