Dynamic header for axios

I have a simple axios construction

this.$http.post(process.env.VUE_APP_API_URL+serverPath, data,
{
  headers: 
  {
    'Cache-Control': 'no-store',
    'Pragma': 'no-cache',
    'Accept': 'application/json',
    'Accept-Language': 'ru-RU, ru;q=0.9, en-US;q=0.8, en;q=0.7',
    'Content-Encoding': 'UTF-8',
    'Content-Language': 'en, ru',
    'Content-MD5': md5(data),
    'Content-Type': 'application/json',
    'Etag': localStorage.getItem('tag')
 }
})
.then(response => (this.response = response))
.catch(function (error)
  {
    console.error(error)
    return false
  }
)

If tag not exists, a server return an error “Etag has undefined type object”, so how to make ‘Etag’ dynamic?

const headers =  {
    'Cache-Control': 'no-store',
    'Pragma': 'no-cache',
    'Accept': 'application/json',
    'Accept-Language': 'ru-RU, ru;q=0.9, en-US;q=0.8, en;q=0.7',
    'Content-Encoding': 'UTF-8',
    'Content-Language': 'en, ru',
    'Content-MD5': md5(data),
    'Content-Type': 'application/json',
 }
if ( localStorage.getItem('tag')) {
  headers.Etag =  localStorage.getItem('tag')
}
this.$http.post(process.env.VUE_APP_API_URL+serverPath, data, { headers })
.then(response => (this.response = response))
.catch(function (error)
  {
    console.error(error)
    return false
  }
)

Yes, I came to the same decision, but I thought that there are better options