NestJS · Senior · Question 49 of 75
How can one interceptor implement idempotency keys for POST endpoints?
- 1Return 409 for every repeated POST
- ✓Correct answer: Read the
Idempotency-Keyheader, return a stored response if the key was seen, otherwise lock the key, callnext.handle()and store the result - 3Interceptors can't access headers
Explanation
Store keys in Redis or the database with the request hash; handle concurrent requests with the same key via a lock.