Answer the question
In order to leave comments, you need to log in
How to get JSON from POST object NODE JS + EXPRESS?
There is a code:
const express = require('express')
const session = require('express-session');
const axios = require('axios')
const bodyParser = require("body-parser");
const app = express()
const port = 3000
const sessionOptions = {
secret: '123456',
cookie: {
maxAge:269999999999
},
saveUninitialized: true,
resave:true
};
const urlcodedParser = app.use(bodyParser.urlencoded({ extended : false}));
app.use(session(sessionOptions));
app.get('/', (request, response) => {
response.send('Hello from Express!')
})
app.post('/test', (rq,rs) =>{
console.log(rq.body);
})
Answer the question
In order to leave comments, you need to log in
const bodyParser = require("body-parser");
const app = express()
// надо же подключить к аппу
// Body parser middleware
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
https://www.npmjs.com/package/body-parser
Press CTRL + F and type this: bodyParser.json([options]), there will be some useful information about JSON in body-parser
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question