Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: remove unused params #5315

Conversation

vakhid-shagmanov
Copy link

No description provided.

@vakhid-shagmanov
Copy link
Author

why test .expect('Supports: text/plain, text/html, application/json') failed ?

@krzysdz
Copy link
Contributor

krzysdz commented Nov 13, 2023

why test .expect('Supports: text/plain, text/html, application/json') failed ?

Number of function parameters matters for declaring error handling middleware. function(err, req, res, next) - must have 4 parameters (including next, even if unused), otherwise it will be considered a normal middleware.

@vakhid-shagmanov
Copy link
Author

@krzysdz even if not used?

@krzysdz
Copy link
Contributor

krzysdz commented Nov 13, 2023

Yes, number of function parameters is the only thing Express can use to distinguish normal and error-handling middleware, because both are just passed to router.use().

Official docs: https://expressjs.com/en/guide/error-handling.html#writing-error-handlers
Another question regarding the number of parameters and error handling middleware: #5065

@vakhid-shagmanov
Copy link
Author

@krzysdz thanks for answering the questions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants