LOGBOOK

HELP

Quiz Entry - updated: 2026.06.20

How do you handle loading states when fetching data?

Set a loading flag before the request and clear it in a finally block, updating the UI to show a spinner, the data, or an error.

async function loadData() {
  setLoading(true);
  try {
    const response = await fetch('/api/data');
    const data = await response.json();
    renderData(data);
  } catch (error) {
    showError('Failed to load data');
  } finally {
    setLoading(false);
  }
}

Show spinners/skeletons during loading, error messages on failure.

From Quiz: WEBT / Backend Integration | Updated: Jun 20, 2026