DEV Community

Discussion on: Twilio Hackathon Help Thread

Collapse
 
petr7555 profile image
Petr Janik • Edited

Hi. I use Autopilot. Inside, I have a task with action "redirect", which redirects to my express server. I know I could use Twilio functions, but I also need to access DB. I would like to process the request sent from Twilio in express. But I am unable to extract the data from request. Both req.params and req.query are empty.

EDIT: I changed method on both sides to GET and now it works.

EDIT2: The problem has emerged again. I need to use POST method to be able to access Memory. But params, query and body are all empty.

EDIT3: The solution was to use

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
    extended: false
}));
Collapse
 
dkundel profile image
Dominik Kundel

I'm glad you were able to unblock yourself. Yes you have to use the app.use(bodyParser.urlencoded({ extended: false})) option because Twilio performs HTTP POST requests with the data type of application/x-www-form-urlencoded and Express has removed automatic body parsing from their implementation some time ago.