const baseURL = 'https://cxcygl.lnnu.edu.cn/lnsf';

const fetchReq = {
  get(url, params = {}) {
    // 拼接参数
    const queryString = new URLSearchParams(params).toString()
    const fullUrl = baseURL + url + (queryString ? '?' + queryString : '')
    return fetch(fullUrl).then(res => res.json())
  },

  post(url, data) {
    return fetch(baseURL + url, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify(data)
    }).then(res => res.json())
  }
}
