首页 > 移动平台 > 详细

axios结合面向对象封装

时间:2021-03-03 15:03:54      阅读:41      评论:0      收藏:0      [点我收藏+]

function CommonAPI(url, getAPIFn, header) {
    this.url = url;
    this.header = header;
    this[getAPIFn] = async (data) => {
      var result = await axios({
        url: this.url,
        method: "post",
        data: data,
        headers: this.header
      }).then((res) => {
        return (res.data)
      }).catch(req => {
        throw req
      })
      return result
    }
  }

axios结合面向对象封装

原文:https://www.cnblogs.com/hksstwtaugmy/p/14472856.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!