According to the API documentation, to receive json as formData from a POST request, one must use body-parser. I have declared it in the gateway service but I can still not receive the formData in my action.
api.service.js
module.exports = {
name: "api",
mixins: [ApiGateway],
settings: {
port: process.env.PORT || 3000,
routes: [{
path: "/api",
aliases: {
"POST users": "users.insertUser",
},
//The API Documentation recomends using the body-parser here
bodyParsers: {
json: true,
urlencoded: { extended: true }
},
}],
// In some example they also set the body-parser here
bodyParsers: {
json: true,
urlencoded: { extended: true }
},
},
};
In the actions service.insertUser action I am supposed to receive the req.body as ctx.params, however it is always empty
My users.service.js
actions: {
insertUser: {
handler(ctx) {
this.logger.info("posting", ctx.params); // -> prints {} instead of the formData
}
}