DEV Community


Discussion on: Axios Tips for Real-World Apps

sovai profile image
Sovai Kean

What about custom headers? how do you implement it within you method?

kevinleedrum profile image
Kevin Lee Drum Author

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,, etc.

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