Chapter 12: Interacting with RESTful APIs
Having completed our REST API, it's now time to interact with it in our React frontend app. We will start by interacting with the unauthenticated endpoints to get questions by using the browser's fetch
function. We will deal with the situation when a user navigates away from a page before data is fetched, preventing state errors.
We will leverage the Auth0 tenant that we set up in the last chapter to securely sign users in and out of our app. We will then use the access token from Auth0 to access protected endpoints. We will also make sure that authenticated users are only able to see options that they have permission to perform.
By the end of this chapter, our frontend will be interacting fully with the backend, securely and robustly.
In this chapter, we'll cover the following topics:
- Using
fetch
to interact with unauthenticated REST API endpoints - Interacting...