I'm using Angular to POST to my API. As I'm dealing with CORS I have set the header as www-form-urlencoded
to avoid the "pre-flight.
$http.post(url, {key1: value1, key2: value2},{"headers":{ "Content-Type" : "application/x-www-form-urlencoded; charset=UTF-8" }}).
success(function(data, status, headers, config) {
}).
error(function(data, status, headers, config) {
});
The problem now is that I can't seem to parse the object being POSTed even though I have this in my server.js
which I thought would do the job:
var bodyParser = require('body-parser');
app.use( bodyParser.urlencoded({ extended: true }));
I'm trying to access the POSTed values with req.body.key1
but I'm getting undefined