Magento 2 Experten — Hyvä Theme, Tailwind CSS & SEO aus einer Hand ›

Fetch API vs. Axios in React: The Comparison

Fetch API versus Axios

~10 Min. Lesezeit Zuletzt aktualisiert am August 8, 2026

Welcome to Phase 5, the final phase of this tutorial: we finally connect our app to a real API. Before we start, a quick comparison of the two most common ways to make HTTP requests in React (and JavaScript in general).

The built-in fetch() function

fetch() is part of every modern browser (and therefore every React web app) – no extra package needed:

fetch('https://example.com/api/products')
  .then((response) => response.json())
  .then((data) => console.log(data))
  .catch((error) => console.error(error));

Axios: the popular alternative

npm install axios
import axios from 'axios';

axios.get('https://example.com/api/products')
  .then((response) => console.log(response.data))
  .catch((error) => console.error(error));

The key differences

fetch()axios
response.json() needed as a separate, second stepresponse.data already automatically parsed
An HTTP error (404, 500) does NOT throw – you have to check response.ok yourselfan HTTP error automatically triggers .catch() / a thrown exception
No built-in timeout, no automatic cancellation of in-flight requestsbuilt-in timeout, AbortController support, automatic JSON stringify for POST data
No install needed, built into the browserExtra dependency (about 15 KB), must be installed

The response.ok part is where most beginners trip up: a 404 ("not found") or 500 ("server error") is, technically, a SUCCESSFUL network response as far as fetch() is concerned – only the CONTENT of the response is an error message. That's why fetch() does NOT automatically land in .catch() on a 404 – you have to check yourself:

fetch('https://example.com/api/products/does-not-exist')
  .then((response) => {
    if (!response.ok) {
      throw new Error(`HTTP error: ${response.status}`);
    }
    return response.json();
  })
  .catch((error) => console.error(error));

Tipp: For this tutorial we'll stick with fetch() (no extra package, and you've already seen the basic principle in the React Native tutorial if you know it) – the response.ok check is the only extra work compared to Axios. In larger projects with many API calls, Axios is often the more pragmatic choice.