In Express.js, to catch errors from a promise within a route, the next function should be called with the ______ as an argument.
- error
- promise
- err
- next
In Express.js, to catch errors from a promise within a route, the next function should be called with the err as an argument. This allows Express.js to recognize it as an error-handling middleware. Passing error, promise, or next itself would not trigger the error handling mechanism in Express.js.
Loading...
Related Quiz
- In a RESTful API, which HTTP method corresponds to the Update operation in CRUD?
- When a package is listed under devDependencies, it means that the package is only required during the ________ of the application.
- You are tasked with ensuring that a web application works seamlessly and that all components interact as expected. Which testing approach would be most suitable to verify the interactions between different components and services?
- You are developing a large-scale application using Pug as a template engine, and you need to create reusable components. How would you create a reusable navigation component in Pug that can be included in multiple views?
- You are designing an authentication system for a new API. The API will be accessed by both web clients and other services. Which authentication strategy would be most suitable to ensure security and scalability?