Skip to content Skip to sidebar Skip to footer

Express Accessing Angular Http Post Data

I have been having trouble accessing the data that is passed to express.js from angular http service. I am using the http service : $http.post('/someUrl', data, config).then(succe

Solution 1:

for POST requests you need body parser (get requests still access data)

var app = require('express')();
var bodyParser = require('body-parser');
var multer = require('multer'); // v1.0.5

app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded

app.post('/api/topic', function (req, res, next) {
  console.log(req.body);
  res.json(req.body);
});

Post a Comment for "Express Accessing Angular Http Post Data"