module.exports = async function cloudApi($url, data) {
  if ($url == "sendError") {
    let res = getCurrentPages()
    let v = wx.getAccountInfoSync()
    data.path = res[res.length - 1].route
    data.env = v.miniProgram.envVersion

    if (data.error) {
      data.error = data.error.toString()
    }
    if (v.miniProgram.version) {
      data.appVersion = v.miniProgram.version
    }
  }
  return await wx.cloud.callFunction({
    name: "api",
    data: {
      $url,
      ...data
    }
  })
}