从请求标头中删除标头“内容类型”

时间:2018-07-16 14:03:00

标签: javascript reactjs axios

我正在尝试从发布请求中删除内容类型标头

const config = {
  transformRequest: [
    function(data, headers) {
      // Do whatever you want to transform the data
      console.log(headers);
      delete headers.post["content-Type"];
      delete headers.get["content-Type"];
      delete headers.common["content-Type"];
      console.log(headers);
      return data;
    }
  ]
};
const request1 = axiosObject.post(urlAPI + "delete/post", post, config);

request1.then(res => {
  console.log(res);
});

但这不起作用。 当我控制台日志标题时,其中没有内容类型, 但是当我看到请求标头时,会出现 Content-Type:text / plain; charset = UTF-8

0 个答案:

没有答案