Rest API - HTTP Status CodesWhich of the following is the correct way to send a 201 Created status code in a Node.js Express REST API?Ares.sendStatus(201);Bres.status(201).json({ message: 'Created' });CAll of the aboveDres.status(201).send('Created');Check Answer
Step-by-Step SolutionSolution:Step 1: Understand Express response methodsres.sendStatus sets status and sends text, res.status sets status and allows chaining send or json.Step 2: Check each optionAll options correctly send a 201 status with a response.Final Answer:All of the above -> Option CQuick Check:Multiple ways to send 201 = B [OK]Quick Trick: Express allows multiple ways to send status and response [OK]Common Mistakes:MISTAKESUsing res.send without statusNot chaining status before sendSending status code as string
Master "HTTP Status Codes" in Rest API9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Rest API Quizzes HTTP Methods - PATCH for partial updates - Quiz 5medium HTTP Status Codes - 400 Bad Request - Quiz 1easy HTTP Status Codes - 400 Bad Request - Quiz 7medium REST API Fundamentals - Client-server architecture - Quiz 15hard REST API Fundamentals - REST vs SOAP vs GraphQL comparison - Quiz 14medium REST API Fundamentals - Resource-based design thinking - Quiz 15hard REST API Fundamentals - REST constraints and principles - Quiz 7medium Request and Response Format - Request body structure - Quiz 3easy Request and Response Format - Why consistent formats improve usability - Quiz 9hard URL and Resource Design - Nested resources - Quiz 7medium