Node.js · Middle · Question 35 of 75
What is a good way to return API errors in a consistent format?
- 1Always return 200 with
{ ok: false } - ✓Correct answer: A JSON body with a stable structure, for example RFC 9457 Problem Details:
type,title,status,detail - 3Return the full stack trace so the client can debug
Explanation
Use correct status codes and a predictable error body. Never send stack traces or internal messages to clients in production.