Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
React

Fetch API in React

Call APIs with fetch inside useEffect or event handlers.

Fetch API in React — a practical guide to React Fetch API with clear examples you can reuse in real projects.

React Tutorial Series (50/103). Prefer one article? Read the complete React tutorial.

Short description

Check res.ok; parse JSON; handle aborts with AbortController.

Fetch in effect

useEffect(() => {
  const ctrl = new AbortController();
  fetch('/api/items', { signal: ctrl.signal })
    .then((r) => r.json())
    .then(setItems)
    .catch(setError);
  return () => ctrl.abort();
}, []);