SAP_CAPbeginner
Node.js service handlers
Use before on after handlers transactions and typed request context
Overview
Use before on after handlers transactions and typed request context
Lessons in this topic
- Node.js service handlers — SAP Guided TutorialWriting before, on and after handlers in CAP Node.js: where validation belongs, how errors reject requests, how each request runs in one transaction, and why side effects such as e-mails must wait until the transaction commits.
Interview questions covered
- Walk me through the handler phases in CAP Node.js and give an example of each.
- Two users order the last copy of a book at the same time. How do you implement this in CAP so you never oversell?
How to study Node.js service handlers
Node.js service handlers has 1 lesson (1 beginner) with about 6 minutes of reading in total. Start with the lesson that matches your level, then read the real project scenario and common mistakes in each one before moving on. After the lessons, say the 2 interview questions out loud in your own words, then check yourself against the model answer in each question (shown once you open it). Use the 4 mock questions to check recall.
Mock test questions covered
Try answering each one before you open the mock test; the answer options and scoring are in the Mock Questions tab.
- Where should input validation for a CREATE request normally go in CAP Node.js?
- An after CREATE handler sends a confirmation e-mail. Later in the same request a constraint fails. What happens?
- What is the safest way to reserve stock in a CAP action under concurrent requests?
- What is the difference between req.error() and req.reject()?