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
From the course: Building React and Django Apps
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Handling creating models with Django REST framework1m 39s
-
(Locked)
Creating a REST API Service class with React and Axios2m 24s
-
(Locked)
Creating a basic form as a React component2m 22s
-
(Locked)
Creating form fields for basic form2m 6s
-
(Locked)
Connecting a React component to a service2m 26s
-
(Locked)
Validating form data with Django REST framework54s
-
(Locked)
Displaying validation errors with React1m 23s
-
(Locked)
-
-
-