A page loads data from your API. How do you handle loading, empty and error states so users are never left confused?
What the interviewer wants to hear
- Design loading, empty, error and success states explicitly
- Use a consistent error format from the API with useful status codes
- Show friendly messages and a retry option, not raw errors
- Distinguish expected errors (404, 422) from unexpected ones (500)
- Log or report unexpected errors with a request ID
Model answer
I treat every data-driven view as having four states: loading, empty, error and success, and I design each one on purpose. While loading I show a skeleton that matches the layout so the page does not jump. If the list is empty I show a helpful message and an action, such as "Create your first project". For errors, the API returns a consistent JSON shape with a proper status code, so the UI can react differently: a 404 shows "not found", a 422 shows field messages, a 401 sends the user to login, and a 500 shows a friendly message with a Retry button. In React I use an error boundary around each section so one failure does not blank the whole page. Unexpected errors are reported to monitoring with a request ID, which I also display so support can find the exact log.
Can you answer it under time pressure?
Take a timed easy round and get scored on every answer.
More easy Full Stack Developer questions
- What happens, step by step, when a user types your app URL into the browser and presses Enter?
- Design the REST API endpoints for a simple blog with posts and comments. What URLs, methods and status codes would you use?
- What is the difference between authentication and authorization? Give an example from a web app.
- You are starting a new e-commerce app. Would you choose a SQL or a NoSQL database, and why?
- Explain client-side rendering, server-side rendering and static site generation. When would you use each?
- In a web app with a React frontend and an API, where should input validation happen, and why?
- How do you manage configuration and secrets across development, staging and production for a full-stack app?
- How would you explain a database index to a junior developer, and how do you decide which columns to index?
- Describe the Git and code review workflow you follow when building a feature on a team.