axios移除拦截器

目录结构如下:
在这里插入图片描述

axios实例有

/**
 *  Axios 实例, ajax请求底层方法
 *  官方文档 [https://github.com/axios/axios]{@link https://github.com/axios/axios}
 *  @module utils/axios
 */

import axios from 'axios'
// axios.defaults.withCredentials = true

/**
 * 取消请求
 * @type {CancelTokenSource}
 * @example
 *
 * import {source} from '@/utils/axios'
 * source.cancel('描述文字....')
 */
export const source = axios.CancelToken.source()

/**
 * Axios实例化参数选项对象
 * @const
 * @type {object}
 * @property {object} headers 请求头对象对象,默认:null
 * @property {number} timeout 超时时间,默认:0, 不限制
 * @property {boolean} withCredentials 是否带上验证信息, 默认:true
 * @property {number} maxContentLength 限制最大发送内容长度,默认:-1 不限制
 */
const config = {
  headers: {
    'Content-Type': 'application/json;charset=UTF-8'
  },
  baseURL:'https://www.abc.com/api',
  timeout: 0,
  responseType: 'json',
  maxContentLength: -1,
  cancelToken: source.token,
  withCredentials:true
}

const service = axios.create(config)


/**
 * Axios 实例
 * @example
 *
 *  // 基础用法
 *  import axios from '@/utils/axios'
 *  axios({
 *    method: 'post',
 *    url: '/user/123',
 *    data: {
 *      firstName: 'Fred',
 *      lastName: 'Flintstone'
 *    }
 *  })
 *
 *  @example
 *
 *  // 实例方法
 *  axios.request(config)
 *  axios.get(url[, config])
 *  axios.delete(url[, config])
 *  axios.head(url[, config])
 *  axios.options(url[, config])
 *  axios.post(url[, data[, config]])
 *  axios.put(url[, data[, config]])
 *  axios.patch(url[, data[, config]])
 *
 * @example config
 * {
*   // `url` is the server URL that will be used for the request
*   url: '/user',
*
*   // `method` is the request method to be used when making the request
*   method: 'get', // default
*
*   // `baseURL` will be prepended to `url` unless `url` is absolute.
*   // It can be convenient to set `baseURL` for an instance of axios to pass relative URLs
*   // to methods of that instance.
*   baseURL: 'https://some-domain.com/api/',
*   // `transformRequest` allows changes to the request data before it is sent to the server
*   // This is only applicable for request methods 'PUT', 'POST', and 'PATCH'
*   // The last function in the array must return a string or an instance of Buffer, ArrayBuffer,
*  
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值