import apiRequest from './apiRequest'

const request = (option: any) => {
  const { url, method, params, data, headersType, responseType } = option
  return apiRequest({
    url,
    method,
    params,
    data,
    responseType,
    headers: {
      'Content-Type': headersType || 'application/json',
    },
  })
}
export default {
  get: <T = any>(option: any) => {
    return request({ method: 'get', ...option }) as unknown as T
  },
  post: <T = any>(option: any) => {
    return request({ method: 'post', ...option }) as unknown as T
  },
  delete: <T = any>(option: any) => {
    return request({ method: 'delete', ...option }) as unknown as T
  },
  put: <T = any>(option: any) => {
    return request({ method: 'put', ...option }) as unknown as T
  },
  patch: <T = any>(option: any) => {
    return request({ method: 'patch', ...option }) as unknown as T
  },
}
