Skip to content

Commit 7cd14d9

Browse files
committed
feat: 提高并发量为10
1 parent 2fee60d commit 7cd14d9

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

index.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22

33
import http from 'wxapp-http';
44

5+
const httpClient = http.create({
6+
maxConcurrent: 10,
7+
timeout: 0,
8+
header: {},
9+
dataType: 'json'
10+
});
11+
512
function generateResponse(res) {
613
let header = res.header || {};
714
let config = res.config || {};
815
return {
9-
ok: ((res.statusCode / 200) | 0) == 1, // 200-299
16+
ok: ((res.statusCode / 200) | 0) === 1, // 200-299
1017
status: res.statusCode,
1118
statusText: res.errMsg,
1219
url: config.url,
@@ -31,7 +38,9 @@ function generateResponse(res) {
3138
entries: () => {
3239
let all = [];
3340
for (let key in header) {
34-
all.push([key, header[key]]);
41+
if (header.hasOwnProperty(key)) {
42+
all.push([key, header[key]]);
43+
}
3544
}
3645
return all;
3746
},
@@ -41,11 +50,11 @@ function generateResponse(res) {
4150
};
4251
}
4352

44-
export default (typeof fetch == 'function'
53+
export default (typeof fetch === 'function'
4554
? fetch.bind()
4655
: function(url, options) {
4756
options = options || {};
48-
return http
57+
return httpClient
4958
.request(options.method || 'get', url, options.body, options.headers)
5059
.then(res => Promise.resolve(generateResponse(res)))
5160
.catch(res => Promise.reject(generateResponse(res)));

0 commit comments

Comments
 (0)