当前位置:   article > 正文

基于axios封装fetch方法及调用_axios 转成fetch

axios 转成fetch

基础axios用法请看axios官网

//依赖于axios对私有ajax进行修改
import Qs from 'qs'
import axios from 'axios'
import router from 'router/index'
import {errorPrompt, loading, closeLoading} from 'util/util'

export const status = {
  SUCCESS: '100',
  NET_ERR: '101',   // 网络连接异常,请稍候再试
  BIZ_ERR: '103', // 业务请求异常
  NO_AUTH: '104'

}

export function fetch(options) {
  return new Promise((resolve, reject) => {
    let instance = axios.create({
      baseURL: process.env.BASE_API,
      timeout: 2000,
      headers: {
        // "tracecode": window.encodeURIComponent(JSON.stringify({
    "ua":"","cv":"20161230","token":"3dwo0onUUsPKVJcP8tk","os":"windows10","app":"kind","ws":"1*1","pkey":"f8caf7d7-a5d4-4710-b06f-28a922b6a467"}))
        "tracecode": commonBizHeader(isManager(options)),
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      transformRequest: [
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/257381
推荐阅读
相关标签
  

闽ICP备14008679号