Skip to main content

Practice ยท 3 of 3

Status Code Selector

Write respond(handler) โ€” handler is one of "create-ok", "create-duplicate", "get-ok", "get-missing", "update-invalid", "delete-ok", "boom". Return { status, body } where: create-ok => 201 + { ok: true }; create-duplicate => 409 + { error: "duplicate" }; get-ok => 200 + { ok: true }; get-missing => 404 + { error: "not-found" }; update-invalid => 400 + { error: "validation" }; delete-ok => 204 + null body; boom => 500 + { error: "internal" }.

Difficulty: intermediate

Back to lesson: Practice: HTTP Mechanics โ€” Practice