Skip to content

Files

Latest commit

 

History

History
16 lines (11 loc) · 1.59 KB

fetching-data-with-ajax-requests.md

File metadata and controls

16 lines (11 loc) · 1.59 KB
id title sidebar_label
fetching-data-with-ajax-requests
Fetching Data with AJAX Requests
Fetching Data

React doesn't prescribe a specific approach to data fetching, but people commonly use either a library like axios or the fetch() API provided by the browser.

The global fetch function allows you to make AJAX requests. It takes in a URL as an input and returns a Promise that resolves to a Response object. You can find more information about fetch here.

A Promise represents the eventual result of an asynchronous operation, you can find more information about Promises here and here. Both axios and fetch() use Promises under the hood. You can also use the async / await syntax to reduce the callback nesting.

Make sure the fetch() API and Promises are available in your target audience's browsers. For example, support in Internet Explorer requires a polyfill.

You can learn more about making AJAX requests from React components in the FAQ entry on the React website.