import axios from './api.request'

export const get = (url, params = {}) => {
  return new Promise((resolve, reject) => {
    axios.request({
      url: url,
      method: 'get',
      params: params,
    }).then(response => {
      resolve(response.data);
    }).catch(err => {
      reject(err)
    })
  })
}

export const post = (url, params = {}) => {
  return new Promise((resolve, reject) => {
    axios.request({
      url: url,
      method: 'post',
      data: params
    }).then(response => {
      resolve(response.data);
    }).catch(err => {
      reject(err)
    })
  })
}

export const patch = (url, params = {}) => {
  return new Promise((resolve, reject) => {
    axios.request({
      url: url,
      method: 'patch',
      data: params
    }).then(response => {
      resolve(response.data);
    }, err => {
      reject(err)
    })
  })
}

export const put = (url, params = {}) => {
  return new Promise((resolve, reject) => {
    axios.request({
      url: url,
      method: 'put',
      data: params
    }).then(response => {
      resolve(response.data);
    }, err => {
      reject(err)
    })
  })
}

export const remove = (url, params = {}) => {
  return new Promise((resolve, reject) => {
    axios.request({
      url: url,
      method: 'POST',
      params: params
    }).then(response => {
      resolve(response.data);
    }, err => {
      reject(err)
    })
  })
}
