Performance: Axios setup and configuration
MEDIUM IMPACT
This affects page load speed and interaction responsiveness by controlling how HTTP requests are made and managed in the app.
import axios from 'axios'; const apiClient = axios.create({ baseURL: 'https://api.example.com', timeout: 5000 }); export default { data() { return { data: null }; }, methods: { async fetchData() { const response = await apiClient.get('/data'); this.data = response.data; } } }
import axios from 'axios'; export default { data() { return { data: null }; }, methods: { fetchData() { axios.get('https://api.example.com/data') .then(response => { this.data = response.data; }); } } }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Direct axios calls everywhere | Minimal | 0 | 0 | [!] OK |
| Single configured axios instance | Minimal | 0 | 0 | [OK] Good |