Summary
This chapter covered how to fetch data by making API requests in three different ways, XMLHttpRequest
, the Fetch API
, and Axios
. Throughout this chapter, we practiced making requests to JSONPlaceholder
and learned several different HTTP
methods. Also, we learned how to get the images from NASA Open API
s in React. At the end of the chapter, the activity showed you how to make requests to Unsplash to display a random photo and statistics.
We compared three different ways, XMLHttpRequest
, Fetch API
, and Axios
, to request data and discussed why we should use Axios
over the other two ways.
We learned what a RESTful API
is and what the five common HTTP
methods are. Furthermore, we talked about the differences between the Accept and Content-Type header, followed by how to test APIs with Postman
.
After that, we learned how to make API requests in React by making requests to NASA Open APIs and searched NASA images by submitting a search term.
With this essential understanding...