I have one route that I use to return some data considering the body parameters.
routes.js
const express = require('express')
const ReportsController = require('./controllers/ReportIngredientController')
const routes = express.Router()
routes.get('/report', ReportsController.show)
module.exports = routes;
I created a postman call to test it and this is the body I am sending
[
{
"name": "acem"
},
{
"name": "sal grosso"
},
{
"name": "caldo de carne"
}
]
but when I try to get the "req.body" at the controller, it is getting empty. Can anyone help with this kind of error?
I got the solution to the problem I had mentioned, in this case, I needed to use params from the Get method.
axios({
method: 'get',
url: "http://192.168.0.2:3333/report",
responseType: 'json',
headers: {},
params: {
name: ["'acem'", "'sal grosso'"]
}
})
.then(function (res) {
// handle success
console.log("######## CARD CALL - IT's OK!!! :: ", res.data);
setRecipeList(res)
})
.catch(function (error) {
console.log('API CALL - /report - error: ',error);
})
that is what I used to get the result I needed and send the query params to the API.
thanks a lot for the answers.