Interacting with RESTful APIs

Having completed the 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 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 only authenticated users are able to see options that they have permission to perform. 

At the end of this chapter, our frontend will be fully interacting 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 with Auth0 from the frontend
  • Controlling authenticated options 
  • Using fetch to interact with authenticated REST API endpoints
  • Stopping a data state being set if the user navigates away from the page
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.54.242