zoukankan      html  css  js  c++  java
  • 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)
     
    })
  • 相关阅读:
    mongo常用查询
    MongoDB
    python连接mongo
    linux 硬盘
    kali 日志
    linux 命令
    grep
    linux shell
    linux 匹配字符串是否为数字
    linux 第一题 计算题
  • 原文地址:https://www.cnblogs.com/dhjy123/p/15475288.html
Copyright © 2011-2022 走看看