By setting the default baseurl in Axios, we don’t need to call the APIs with whole url. Only the endpoint will be required. The simplest procedure of doing this is by creating a separate component file and setting all default parameters there.

Create a component, axios.js –

import axios from 'axios';
const instance = axios.create({baseURL: 'https://www.example.com'});
export default instance

#react js

ReactJS - Setting Default Baseurl in Axios
8.00 GEEK