DestinyHunter / DestinyHunter.github.io

Blog
https://DestinyHunter.cn
1 stars 0 forks source link

axios 发送 application/x-www-form-urlencoded #10

Open DestinyHunter opened 6 years ago

DestinyHunter commented 6 years ago

import axios from 'axios'
import qs from 'qs'
import store from 'store'

// 创建axios实例
const service = axios.create({
  baseURL: process.env.BASE_API + '/Api/V1', // api的base_url
  transformRequest: [function(data) {
    return qs.stringify(data)
  }],
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
  },
  timeout: 5000 // 请求超时时间
})