{"size": 832, "ext": "js", "max_stars_repo_path": "src/network/request.js", "max_stars_repo_name": "971125/smallShopping", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/network/request.js", "max_issues_repo_name": "971125/smallShopping", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/network/request.js", "max_forks_repo_name": "971125/smallShopping", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 18.4888888889, "max_line_length": 61, "alphanum_fraction": 0.6225961538}
import axios from 'axios'

export function request(config) {
  // 1.创建axios的实例
  const instance = axios.create({
    baseURL: 'http://123.207.32.32:8000',
    timeout: 5000
  })

  // 2.axios的拦截器
  // 2.1.请求拦截的作用
  instance.interceptors.request.use(config => {
    return config
  }, err => {
    // console.log(err);
  })

  // 2.2.响应拦截
  instance.interceptors.response.use(res => {
    return res.data
  }, err => {
    console.log(err);
  })

  // 3.发送真正的网络请求
  return instance(config)
}

export async function  req(path){
  let data
  let jspath
  switch(path){
    case "/category/man":jspath="/js/manmock.json";break;
    case "/category/woman":jspath="/js/womanmock.json";break;
  }
   await axios.get(jspath).then(res=>{
   data=res.data
   console.log(path)
  },response=>{
    console.log("error")
  }
  )
  return data
}
