на пост запрос ошибка "Unexpected token o in JSON at position 1" ?? const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors')
const app = express();
app.use(bodyParser.json());
bodyParser.urlencoded({ extended: true })
// app.use(allowCrossDomain);
// const jsonParser = bodyParser.json();
app.use(cors());
app.post('/', (req, res) => {
// res.send('welcome, ' + req.body.username)
console.log(req.body);
})
app.get('/', bodyParser.json(), (req, res) => {
// res.send('welcome, ' + req.body.username)
console.log(req.body);
})
app.listen(3001, () =>{
console.log('Server started');
});
app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.json());
Обсуждают сегодня