index.ts 741 字节
import { LStore } from "@/utils/store";
import { BASE_URL, TIME_OUT } from "./config";
import HYRequest from "./request";

const hyrequest = new HYRequest({
  baseURL: BASE_URL,
  timeout: TIME_OUT,
  interceptors: {

    requestSuccessFn(config) {
      const token = LStore.get('token')
      if (token && config.headers) {
        config.headers['Content-Type'] = 'multipart/form-data;'
        config.headers.token = token
        config.headers['X-Access-Token'] = token
      }
      return config
    },

    responseFailureFn(err) {
      // console.log(err, '相应失败')
      // return err
    },

    requestFailureFn(err) {
      // console.log(err, '请求失败')
      // return err
    }

  }
})

export default hyrequest