0

I am not able to access the body with express.js module. I am sending request with restTemplate in spring boot application. Following is my code for the request

HttpEntity entity1 = new HttpEntity<>(lead, new HttpHeaders());
ResponseEntity<String> htmlResponse = restTemplate.exchange(requestUrl, HttpMethod.POST, entity1, String.class);

On the other hand I am using express.js module to catch this request. Following is the code for that.

app.post('/get_leadcard', function(req, res) {
    console.log(req.body);
}

However when I run this program, It shows that req.body is undefined. What is the right way to do this?

Parth Pandya
  • 113
  • 4

1 Answers1

1

I was missing body-parser middleware in my program. Just by adding following lines it now works.

import bodyParser from 'body-parser';
app.use(bodyParser());
Parth Pandya
  • 113
  • 4