Consuming the REST API with React
This chapter explains networking with React. This is a really important skill that we need in most React apps. We will learn about promises, which make asynchronous code cleaner and more readable. For networking, we will use the fetch
and Axios libraries. As an example, we will use the OpenWeather and GitHub REST APIs to demonstrate how to consume RESTful web services with React. We will also see the React Query library in action.
In this chapter, we will cover the following topics:
- Promises
- Using the
fetch
API - Using the Axios library
- Practical examples
- Handling race conditions
- Using the React Query library