Rahul Vijayan
Follow for more updates
TCS Wings 1 T1 MERN - Set 5
- Jack is designing an API using Express and wants to secure routes with token-based authentication. Which middleware is best suited for validating tokens?
- a)
cors
- b)
helmet
- c) Custom middleware that checks for valid tokens
- d)
express.static
Answer: c) Custom middleware that checks for valid tokens
- Chloe needs to pass a function as a prop to a child component in React. Which data type should she use in the prop?
- a) Object
- b) Function
- c) String
- d) Array
Answer: b) Function
- Ethan is using Express to build a REST API and wants to return JSON data. Which method should he use to send JSON responses?
- a)
res.write
- b)
res.end
- c)
res.sendFile
- d)
res.json
Answer: d) res.json
- Mia has a list of items displayed in a React component. She wants to ensure each item has a unique key to avoid rendering issues. Which attribute should she use for each item?
- a)
id
- b)
ref
- c)
key
- d)
className
Answer: c) key
- Alex needs to store user session data on the client side for a PWA. Which storage method is recommended for sensitive information like tokens?
- a) Local Storage
- b) Session Storage
- c) Cookies with
httpOnly
andSecure
flags - d) IndexedDB
Answer: c) Cookies with httpOnly
and Secure
flags
- Sara wants to perform an operation in MongoDB to retrieve documents where a certain field exists. Which operator should she use?
- a)
$exists
- b)
$in
- c)
$gte
- d)
$lte
Answer: a) $exists
- Liam is handling errors globally in his Express app. What should he pass as the first argument to the error-handling middleware function?
- a)
req
- b)
res
- c)
error
- d)
next
Answer: c) error
- Emma is optimizing her API calls with
Axios
in React and wants to cancel an API request if the component unmounts. Which method will allow her to achieve this?
- a)
AbortController
- b)
Promise.all
- c)
useMemo
- d)
React.memo
Answer: a) AbortController
- Noah is implementing a search function in MongoDB that performs case-insensitive searches. Which MongoDB feature will help him achieve this?
- a)
$regex
- b)
$text
- c)
$caseSensitive
- d)
$group
Answer: a) $regex
- Lily is handling form validation in her React app and wants to display an error message if a user leaves an input field blank. Which method is commonly used for client-side validation in React?
- a)
window.alert
- b)
setState
- c)
input validation with controlled components
- d)
console.log
Answer: c) input validation with controlled components
No comments:
Post a Comment