MCPcopy
hub / github.com/EastWorld/wechat-app-mall / request

Function request

miniprogram_npm/apifm-wxapi/index.js:102–127  ·  view source on GitHub ↗
(url, needSubDomain, method, data)

Source from the content-addressed store, hash-verified

100var merchantId = '0';
101
102var request = function request(url, needSubDomain, method, data) {
103 var _url = API_BASE_URL + (needSubDomain ? '/' + subDomain : '') + url;
104 if (url.indexOf("http") == 0 ) {
105 _url = url
106 }
107 var header = {
108 'Content-Type': 'application/x-www-form-urlencoded'
109 };
110 return new Promise(function (resolve, reject) {
111 wx.request({
112 url: _url,
113 method: method,
114 data: data,
115 header: header,
116 success: function success(request) {
117 resolve(request.data);
118 },
119 fail: function fail(error) {
120 reject(error);
121 },
122 complete: function complete(aaa) {
123 // 加载完成
124 }
125 });
126 });
127};
128
129/**
130 * 小程序的promise没有finally方法,自己扩展下

Callers 1

index.jsFile · 0.85

Calls 1

rejectFunction · 0.85

Tested by

no test coverage detected