axios1.0.0都更新了什么?

1,732 阅读1分钟

image.png

2022-10-04 axios发布了1.0.0版本 来看看都更新了什么 我记得我学前端开始的时候 axios就一直是0.2x.xx 没想到第一个大版本来的这么快

  1. 尝试在创建错误时捕获堆栈跟踪,以便维护关于错误来源的上下文。

在发生错误时可以获得更多的信息

  1. 添加了AxiosError类
// Expose AxiosError class |                                                       |
axios.AxiosError = require('../lib/core/AxiosError');
  1. 使用Rollup构建
  2. 清楚堆栈中的所有拦截器
InterceptorManager.prototype.clear = function clear() {
    if (this.handlers) {
        this.handlers = null;
    }
};
  1. axios-url-template - Axios interceptor adding support for URL templates.
  2. @react-cmpt/react-request-hook - A React hook plugin for axios. Lightweight and less change.
  3. Add 2 new options to AxiosRequestConfig:

transformSuccessResponse: 仅为成功响应转换响应数据。 transformErrorResponse: 仅为错误响应转换响应数据。

  1. 添加blob到浏览器支持的协议列表