1.1.0 • Published 4 years ago

xr-ajax v1.1.0

Weekly downloads
2
License
ISC
Repository
-
Last release
4 years ago

基于 Axios 简单封装的 web 端 http 请求库。

✨ 特点

  • 默认超时时间 45 s
  • 200 ~ 500 状态码全部解析
  • withCredentials 默认为 true
  • 支持取消所有请求
  • 支持通过 post 方式发送简单的 formdata

📦 安装

npm i xr-ajax

🔨 使用

import XrAjax from 'xr-ajax';

const ajax = new XrAjax(/* AxiosRequestConfig 传入新的配置会覆盖原有配置 */);
ajax.http.interceptors.request.use(/* 请求拦截器 */);
ajax.http.interceptors.response.use(/* 响应拦截器 */);

ajax
  .get('/user')
  .then(res => {
    /**/
  })
  .catch(err => {
    /**/
  });

TODO

  • 上传文件 upload
  • 防抖
  • 支持依赖注入
  • 支持Observe
1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago