good day!
Please tell there are misstake. When project run - CountValue is {}
i have fetch to send data from react:
let data = {pp: number};
data = JSON.stringify(data);
fetch('http://localhost:3001/number', {
method: 'post',
body: data
}).then(function(responce) {
console.log('data submit success');
}).catch(function(error) {
console.log('got err', error);
})
this is the server code
var bodyParser= require('body-parser');
app.use(bodyParser.json());
router.post('/', function (req, res) {
var countValue = req.body;
console.log('CountValue is', countValue);
});
How should I send data?