Custom headers can be set in Axios requests, which is useful when working with APIs that require authentication tokens or specific content types.
axios.get('https://jsonplaceholder.typicode.com/posts/1', {
headers: {
'Authorization': 'Bearer YOUR_TOKEN_HERE'
}
})
.then(response => {
console.log('Post data:', response.data);
})
.catch(error => {
console.error('Error fetching data:', error);
});