Hrolgar
Hrolgar

Reputation: 115

Order of Request and Respond in Express

In the Express app.get() method, is there any difference in what order I write response and request? I mean between app.get("/", (req, res) => or app.get("/", (res, req) =>?

Upvotes: 0

Views: 185

Answers (1)

Wyck
Wyck

Reputation: 11760

Yes, it matters what order they are in, because they are positional arguments. Technically you can assign any name though.

(req, res) => is the canonical form.

You could even write

(request, response) =>

But if you write (res, req) => then you are accepting the request in a variable called res and the response in a variable called req. So, please don't do that. Because coworkers can be vengeful.

Upvotes: 3

Related Questions