From the course: Building React and Django Apps

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Creating a REST API Service class with React and Axios

Creating a REST API Service class with React and Axios

From the course: Building React and Django Apps

Start my 1-month free trial

Creating a REST API Service class with React and Axios

- We've already worked on the ServiceApi class, so let's update the retrieveWishList method to properly return all the items that are on the user's wish list. Going to be using the config for HTP request methods and then returning a new Promise called Axios.get method pointing to the wish lists API URL. And when we get a response from this API call, we're going to be resolving with the response data. We've used the get config method a few times before, so let's dig in and see what it actually does. First, it asynchronously retrieves the application OAuth access token, then it sets up the authorization field of the header with the given access token. Finally, it resolves the promise with the config. Let's see what getAccessToken does. As you can see, it resolves this promise immediately if the access token has already been set. Otherwise, we're going to be using a grant type of client_credentials passing in the client_ID and…

Contents