index.js 1.02 KB
import axios from "./axios";
let instance = axios();

export default {
  get(url, params, headers) {
    let options = {};

    if (params) {
      options.params = params;
    }
    if (headers) {
      options.headers = headers;
    }
    return instance.get(url, options);
  },
  post(url, data, headers, params) {
    let options = {};

    if (params) {
      options.params = params;
    }
    if (headers) {
      options.headers = headers;
    }
    return instance.post(url, data, options);
  },
  put(url, params, headers) {
    let options = {};

    if (headers) {
      options.headers = headers;
    }
    return instance.put(url, params, options);
  },
  post2(url, params, headers) {
    let options = {};

    if (headers) {
      options.headers = headers;
    }
    return instance.post(url, params, options);
  },
  delete(url, params, headers) {
    let options = {};

    if (params) {
      options.data = params
    }
    if (headers) {
      options.headers = headers;
    }
    return instance.delete(url, options);
  }
};