From the course: Build Modern Web Apps with React, Hooks, State Management, and APIs Using Vite or Next.js

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Setting up Axios client

Setting up Axios client

Hello, and welcome back. In this video, we are going to see how we can set up XEOs in React application the production way. In the production world applications, we usually create a separate API client, which is underlying going to use the XEOs. So in future, if there are going to be any other client that we want to use, we have only one configuration file where we need to make the changes, not everywhere in the code. Consider that you have to use this API URL about 50 to 60 times in your multiple components. So every time you develop a component, you don't have to write this complete path, is just a unnecessary redoing of things. which You should only type the dynamic part which is going to change, for example, slash posts, slash users, slash invoice, etc. And this should be your base URL. We can do that by creating Xeos object using the create function that it provides. In that function, we can have the base URL, which can be the base URL of your API, which is never going to change.…

Contents