You can set up global defaults for Axios that apply to all requests. This can include setting default headers, base URLs, and timeouts.
axios.defaults.baseURL = 'https://jsonplaceholder.typicode.com';
axios.defaults.headers.common['Authorization'] = 'Bearer YOUR_TOKEN';
axios.defaults.timeout = 5000;
// Making a request with global defaults
axios.get('/posts')
.then(response => {
console.log('Data:', response.data);
});
Leave a Reply