Request Configuration in JavaScript
From the Axios cheat sheet · Installation & Basic Requests · verified Jul 2026
Request Configuration
Configure timeout, headers, query params, and more
javascript
// Basic config options
const response = await axios.get('/api/users', {
params: { page: 1, limit: 10 },
timeout: 5000,
headers: {
'Authorization': 'Bearer token123',
'Custom-Header': 'value'
}
});
// Base URL and default config
const api = axios.create({
baseURL: 'https://api.example.com',
timeout: 10000,
headers: { 'X-Custom-Header': 'value' }
});
// Use custom instance
const users = await api.get('/users');✅ Create instances with axios.create() for reusable config
💡 Use params object for query strings - auto URL-encoded
🔍 timeout applies to both connection and response time
⚡ Set baseURL once, use relative paths in all requests
configtimeoutheadersparamsbaseurl