📜  将变量设置为标头 axios - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:47.634000             🧑  作者: Mango

代码示例3
let instance = axios.create({
  headers: {
    post: {        // can be common or any other method
      header1: 'value1'
    }
  }
})

//- or after instance has been created
instance.defaults.headers.post['header1'] = 'value'

//- or before a request is made
// using Interceptors
instance.interceptors.request.use(config => {
  config.headers.post['header1'] = 'value';
  return config;
});