node js send post request with body code example
Example 1: read body of post request nodejs
app.use(express.urlencoded({ extended: true }));
console.log(req.body);
Example 2: node send post request
const axios = require('axios')
axios
.post('https://whatever.com/todos', {
todo: 'Buy the milk'
})
.then(res => {
console.log(`statusCode: ${res.statusCode}`)
console.log(res)
})
.catch(error => {
console.error(error)
})