The Client Layer — Concept Check
Questions on The Client Layer. One module that owns the base URL, auth, error normalisation and types. Components should never see a fetch call or a status code.
Questions in this quiz
7 questions on The Client Layer — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A developer notices that their component is making multiple fetch calls with inconsistent auth headers. What is the likely issue?
- AThe component lacks proper error handling.
- BThe client layer is not being used to centralize fetch calls.
- CThe base URL is incorrect in the client layer.
- DThe API endpoint is down.
2.You are using a client layer that generates types from an OpenAPI schema. What problem does this prevent?
- AInconsistent API base URLs across components.
- BMissing auth tokens in API requests.
- CDrift between backend models and frontend interfaces.
- DIncorrect HTTP methods being used.
3.A developer implements a fetch call directly in a component without using the client layer. What might be a consequence?
- AImproved performance due to direct fetch calls.
- BInconsistent error handling across the application.
- CEnhanced security with direct token usage.
- DAutomatic retry logic is applied.
4.Why might a server component see an anonymous user while the same call works in the browser?
- AThe client layer does not support server-side rendering.
- BThe API endpoint requires a different HTTP method.
- CCookies are not forwarded explicitly in server-side calls.
- DThe server component is missing a base URL.
5.A developer is confused about why their component doesn't receive a status code from the API. What is the reason?
- AThe client layer abstracts away status codes.
- BThe API endpoint is not returning any response.
- CThe fetch call is missing the credentials option.
- DThe status code is returned as a custom header.
6.A developer wants to add a request timeout to their API calls. Where should this be implemented?
- AIn the backend server configuration.
- BDirectly in each component making the call.
- CIn the client layer, using AbortSignal.
- DIn the OpenAPI schema generation script.
7.What is the benefit of using 'credentials: include' in the client layer?
- AIt ensures cookies are sent with every request.
- BIt logs all API requests for debugging.
- CIt generates types from the OpenAPI schema.
- DIt automatically retries failed requests.