Friday 28 April 2017

How to read json object sent over post request and save/append to in memory json object?

I want to read the sent request and save in the following json object. console.log does not even log the data to console. I also tried JSON.Parse() but it didn't work.

var express = require('express');
var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
  extended: true
}));
app.post('/addteacher', function(request, response) {
  console.log(request.body);
}); 
// var inMemory = { teacher: { 1: { id: 1, name: 'name example 1', age: 23, job: 'example job', co-workers: [] }, } };



via Raj

No comments:

Post a Comment