How do you design a networking layer on URLSession: endpoint, client, errors?
The gist
A good networking layer separates three responsibilities: the request description (Endpoint — a value with no execution logic), the client that turns the description into a URLRequest, executes it and validates the response, and typed errors the UI uses to decide what to show. Cross-cutting concerns — auth, logging, common headers — live in interceptors instead of being copied into every endpoint.
Quality bar: a new request is added with one declaration, and the client is tested without the network and without changing production code.
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep