Alexander Zeitler
Alexander Zeitler

Reputation: 13089

Set method to be called by Express.js as param

When using Express normally you use app.post('/path') or app.get('/path') to define routes.

Does Express also provide a function to define routes like this app.route('POST', '/path') (where route is the function I'm looking for)?

Upvotes: 0

Views: 84

Answers (1)

Quoc-Anh Nguyen
Quoc-Anh Nguyen

Reputation: 5056

You can programmatically select method with bracket notation. For example:

app['post']('/path')
app['post']('/path-2')
app['get']('/path')

Upvotes: 1

Related Questions