Skip to main content

Practice ยท 3 of 3

Typed-Feel Client

Write createTypedClient(fetchImpl) where every method validates BEFORE returning: - getTask(id) โ€” fetches /tasks/{id}; if the body passes isTaskDTO return { ok: true, task }; a 404 returns { ok: false, reason: "not-found" }; a malformed body returns { ok: false, reason: "invalid" } - listTasks() โ€” fetches /tasks; valid list โ†’ { ok: true, tasks }; malformed โ†’ { ok: false, reason: "invalid" } - the fake fetchImpl(url) returns { ok, status, json: async () => body }

Difficulty: intermediate

Back to lesson: Practice: Mini Build: Typed API Model