REST JSON APIs
REST maps HTTP verbs to actions: GET read, POST create, PUT/PATCH update, DELETE remove. Return JSON and proper status codes.
- 201 Created for successful POST.
- 400 for bad input; 401/403 for auth; 500 for unexpected errors.
- Keep URLs noun-based: /tasks, /tasks/:id.
const status = 201;
console.log(status, "created");
After you read this chapter, use Write (when available) and Quiz on this page to lock it in.