api.js 354 B

123456789101112131415161718192021
  1. const { api } = require("./apiConfig");
  2. function getApi(url, data = {}) {
  3. return api(url, data, "get");
  4. }
  5. /**
  6. * 向指定URL发送POST请求
  7. *
  8. * @param url 请求的URL
  9. * @param data 请求体数据
  10. * @returns 返回请求的结果
  11. */
  12. function postApi(url, data) {
  13. return api(url, data, "post");
  14. }
  15. module.exports = {
  16. getApi,
  17. postApi,
  18. };