Creating a repository folder
First, create a folder in the root directory or src
folder by running the following command:
mkdir repositories
We will call ours repositories
. This folder will contain all your repositories and the HTTP client configurations.
Creating a clients folder
We will create a Clients
folder inside the newly created repositories
folder. What will be inside this folder are the different HTTP clients used.
Sometimes, due to the nature of the project, some projects might require several HTTP clients to make API calls due to different reasons. One can be a fallback if the default refuses to connect.
Hence, creating a Clients
folder is crucial to configure all the HTTP clients at once. Run the following command to create one:
cd repositories && mkdir Clients
Creating an xxxClient.js class
You can create a class file corresponding to the HTTP client you are using. The naming is subjective, and for Axios, we will create an AxiosClient...