If you are using REST API's, it is very likely you will use Axios. In this tutorial, we take a look at using React Axios together. Both these libraries are able to work very well together, and AXIOS can get and post data directly into your applications store or state.
Topics we cover in this video include:
- What is Axios and how is it used
- Installing axios into a react project
- Importing and setting an instance of Axios with a baseURL
- Performing a get request with axios, and saving it to state
- Performing a post request with axios to the rest API database
- Performing a patch request with axios to update current data
- Deleting stuff, by using a delete request and removing an item
- Using async functions with axios, inside try catch loops
- Adding error handling with and without async functions
- Using await with async as part of the axios workflow
- Setting custom headers in axios such as login tokens or API keys
Hoping this gives anyone who is planning to use axios in a react project a good in-depth understanding. If there is anything I might have left out or you are interested in my covering, please let me know!
Follow and support me:
Special thanks if you subscribe to my channel :)
Want to see more:
I will try to post new great content every day. Here are the latest items: