Why doesn't the request object come to the server?
Request:
fetch('/api/teacher/createTest', { method: 'post', body: JSON.stringify(this.state) }) .then(() => { console.log('create test', JSON.stringify(this.state)); }); The generated query seems to look fine:
create test {"id":1497705421652,"forGroups":[],"name":"","subscribers":[],"questionsCount":0,"questions":[]} Handler on server:
app.post('/api/teacher/createTest', (req, res) => { console.log(req.body); }); This is what it displays (server console):
body-parser is connected:
app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.json()); Where is my mistake?