Having an issue when trying to send a JSON Object from an AngularJS $http service to an Express Server. The server receives an empty object: "{}"
I've looked at this topic, but it hasn't resolved my problem: angular post json to express
This is the code for the Angular client:
self.postTicket = function(ticket){
$http({
url: baseUrl+"features/",
method: "POST",
body: ticket,
headers: {'Content-Type': 'application/json'}})
}
I have verified that the "ticket" object is not empty
And here is the code for the Express server:
var express = require("express");
var request = require("request");
var bodyParser = require('body-parser')
var app = express();
app.use(bodyParser.json({}));
app.post('*', function (req, res) {
console.log(req.body);
res.status(200).send('OK');
});
app.listen(9000);
Any help in resolving this issue would be greatly appreciated. Thank you.