Rahul Vijayan
Follow for more updates
TCS Wings 1 T1 MERN - Set 7
- Mason wants to handle asynchronous errors in his Express routes without using
try-catch
blocks in every route. Which helper function pattern can streamline this process?
- a) Middleware chaining
- b) Wrapper function that returns a promise
- c) Logging middleware
- d) Error-handler in route itself
Answer: b) Wrapper function that returns a promise
- Harper is using MongoDB's
$aggregate
to calculate the total number of items in each category. Which stage allows her to group data by a category field?
- a)
$match
- b)
$project
- c)
$group
- d)
$sort
Answer: c) $group
- Noah is using
axios
to fetch data in his React component and notices aCORS
error in the console. What should he configure in the Express server to resolve this?
- a) Enable
body-parser
- b) Use the
cors
middleware - c) Use the
helmet
package - d) Change the HTTP method
Answer: b) Use the cors
middleware
- Grace wants her React component to run a specific function only when a dependency array value changes. Which hook will help her achieve this?
- a)
useState
- b)
useEffect
- c)
useMemo
- d)
useCallback
Answer: b) useEffect
- Oliver is updating a document in MongoDB and wants only one field to be modified while leaving the rest unchanged. Which MongoDB operator should he use?
- a)
$set
- b)
$push
- c)
$pull
- d)
$unset
Answer: a) $set
- Ella wants her React component to store some data that should only reset when the component unmounts. Which React feature will help her achieve this?
- a)
useState
- b)
useEffect
- c)
useRef
- d)
useContext
Answer: c) useRef
- Ava wants to ensure a middleware runs on every request to her Express server. Where should she place this middleware in her server configuration?
- a) Before all route definitions
- b) After all route definitions
- c) Inside each route handler
- d) Inside
app.listen
Answer: a) Before all route definitions
- Lucas is developing a CRUD API using Express and MongoDB. Which HTTP method is used to delete a specific document based on an ID in a RESTful API?
- a) POST
- b) PUT
- c) DELETE
- d) GET
Answer: c) DELETE
- Amelia is using MongoDB and wants to delete multiple documents that match a specific criterion. Which method should she use?
- a)
delete
- b)
deleteOne
- c)
deleteMany
- d)
remove
Answer: c) deleteMany
- Ethan is setting up an API in Express that requires authentication. Which HTTP status code should he return if the user provides invalid credentials?
- a) 200
- b) 403
- c) 401
- d) 404
Answer: c) 401
No comments:
Post a Comment