Express.js Interview Questions and Answers
Ques 26. Explain the concept of 'Promise' in the context of asynchronous operations in Express.js.
Promises in Express.js are used to handle asynchronous operations, providing a cleaner and more readable way to structure asynchronous code.
Ques 27. What is the role of the 'express.json()' middleware?
'express.json()' is a middleware that parses incoming JSON requests, populating the 'req.body' property with the parsed data.
Ques 28. Explain the purpose of the 'express.static()' middleware.
'express.static()' is a middleware that serves static files, such as images, CSS, and JavaScript files, from a specified directory.
Ques 29. How can you handle query parameters in Express.js?
You can handle query parameters in Express.js using the 'req.query' object, which contains key-value pairs of the query parameters.
Ques 30. Explain the purpose of the 'express.urlencoded()' middleware.
'express.urlencoded()' is a middleware that parses incoming requests with URL-encoded payloads and is based on the 'body-parser' library.
Most helpful rated by users: