'how to acess data from axious post request on node backend?

I am trying to send a data object to backend using axios... the question is should I use axios at back end as well ? I don't seem to be able to get the value.

 axios({
      method: 'post',
      url: '/encrypt',
      data: {
        firstName: 'Fred',
        lastName: 'Flintstone',
      },
      //headers: {'Authorization': 'Bearer ...'}
    });

app.post('/encrypt', (request, response) => {
  console.log(request.body, 'Request................');
});


Solution 1:[1]

Try to fix your code and write according to the syntax. Axios returns a promise.

 axios.post('/encrypt', {
    firstName: 'Fred',
    lastName: 'Flintstone }).then(function (response) {
console.log(response)}).catch(function (error) {
console.log(error)});

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yarin Levi