axios结合面向对象封装


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结合面向对象封装

上一篇:c# lock 关键字讲解


下一篇:tensorflow:Entity <bound method Dense AssertionError: Bad argument number for Name: 3, expecting 4