DEV Community

Discussion on: Axios Tips for Real-World Apps

Collapse
 
kevinleedrum profile image
Kevin Lee Drum

If you need to send custom headers with values that can change with the requests, you can always pass additional arguments to your methods, which can then be passed as part of the config for axios.get, axios.post, etc.

export default {
  getComments: (params, language) => {
    const headers = { 'Accept-Language': language }
    return axios.get(`${API}/comments`, params, { headers })
  }
}