微信小程序封装请求接口

var rootDocment = 'https://123.com';//你的域名
function postData(url, data, cb) {

wx.request({

      url: rootDocment + url,
      data: data,
      method: 'post',
      success: function (res) {
        return typeof cb == "function" && cb(res)
      },
      fail: function () {
        return typeof cb == "function" && cb(false)
      }
    })
}

 

 

posted @ 2019-09-06 23:15  一个小小前端  阅读(1777)  评论(0编辑  收藏  举报