import api from './api.js'

const fetch = (key, data = {}, transform = true, loadingTitle) => {
  return new Promise(resolve => {
    
    const callback = (res) => {
      if (!transform) {
        resolve(res)
        return
      }
      if (res.code == 200) {
        resolve(res.result)
      }
    }

    api(key, data, callback, loadingTitle)
  })
}

export default fetch
