setHeader not working

MLDMoritz
0
MLDMoritz
commented 4 months ago

Version

v5.8.0

Reproduction link

http://example.com

Steps to reproduce

$axios.setHeader('Content-Type', 'application/ld+json', [
    'get',
    'post',
    'delete'
  ])
  $axios.setHeader('Content-Type', 'application/merge-patch+json', 'patch')

Results in a correct config but axios is not picking up the correct headers for the requested method, eg patch.

It uses config.headers['Content-Type'] instead of config.headers.patch['Content-Type']

What is expected ?

Correct header sent on PATCH request

What is actually happening?

PATCH request uses default header

Additional comments?

This is the config.headers object logged in $axios.onRequest:

common: {Accept: "application/ld+json", Authorization: "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYX…xhHiztfOFfJ9rIdvhiRz1oUhMm7sSoWrgNNlgOZwCpfJ8Xovw"}
delete: {Content-Type: "application/ld+json"}
get: {Content-Type: "application/ld+json"}
head: {}
post: {Content-Type: "application/ld+json"}
put: {Content-Type: "application/x-www-form-urlencoded"}
patch: {Content-Type: "application/merge-patch+json"}
Content-Type: "application/json;charset=utf-8"

Setting the header in the request itself works fine and sends correct header:

this.$axios
      .$patch(`users/${user.id}`, user, {
        headers: {
          'Content-Type': 'application/merge-patch+json'
        }
      })
bug
0
mrleblanc101
0
mrleblanc101
commented 3 months ago

Same

0
Informations
Bug ReportOpen
#c308 - Created 4 months ago