Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to combine app.get and app.post in Express?

I am working with facebook app canvas which requires post. I am using express to handle app.post('/') and app.get('/'). Is it possible to combine these in a single function?

like image 845
Radoslav Avatar asked Mar 28 '12 15:03

Radoslav


1 Answers

Aside of binding same function to POST and GET as suggested by JustSid in other answer you may use app.all('/', handler) to route all request types to function.

like image 111
Juicy Scripter Avatar answered Oct 11 '22 14:10

Juicy Scripter