• axios 使用 v3


    import axios from 'axios'
    import store from '@/store'
    import Qs from 'qs'
    import constv from '@/config/constv'
    import { getToken } from '@/utils/auth'
    import { Modal, message } from 'ant-design-vue'
    
    const service = axios.create({
      baseURL: `${constv.API_URL}`,
      timeout: 20000,
      transformRequest: params => Qs.stringify(params) // 参数格式化 qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' }) => 'a=b&a=c'
      // paramsSerializer: params => Qs.stringify(params, { arrayFormat: 'repeat' }) // 参数格式化 qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' }) => 'a=b&a=c'
    })
    
    service.interceptors.request.use(config => {
      if (config.url.indexOf('get_new_all_order_excel') > -1) {
        config.timeout = 300000 // 600s 10min
      }
      const token = getToken()
      if (token) {
        config.headers['token'] = token
      }
      return config
    }, error => {
      message.error('请求超时,请稍后重试!')
      return Promise.reject(error)
     
    })
  • 相关阅读:
    GUC-3 模拟CAS算法
    GUC-2 原子性
    GUC-1 volatile
    NIO-5补充
    NIO-4pipe
    NIO-3网络通信(非阻塞)
    NIO-3网络通信
    NIO-1缓冲区(Buffer)
    NIO-2通道(Channel)
    eclipse安装spring boot插件spring tool suite
  • 原文地址:https://www.cnblogs.com/dhjy123/p/15475288.html
Copyright © 2020-2023  润新知