File tree 1 file changed +13
-4
lines changed
1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import http from 'wxapp-http' ;
4
4
5
+ const httpClient = http . create ( {
6
+ maxConcurrent : 10 ,
7
+ timeout : 0 ,
8
+ header : { } ,
9
+ dataType : 'json'
10
+ } ) ;
11
+
5
12
function generateResponse ( res ) {
6
13
let header = res . header || { } ;
7
14
let config = res . config || { } ;
8
15
return {
9
- ok : ( ( res . statusCode / 200 ) | 0 ) == 1 , // 200-299
16
+ ok : ( ( res . statusCode / 200 ) | 0 ) === 1 , // 200-299
10
17
status : res . statusCode ,
11
18
statusText : res . errMsg ,
12
19
url : config . url ,
@@ -31,7 +38,9 @@ function generateResponse(res) {
31
38
entries : ( ) => {
32
39
let all = [ ] ;
33
40
for ( let key in header ) {
34
- all . push ( [ key , header [ key ] ] ) ;
41
+ if ( header . hasOwnProperty ( key ) ) {
42
+ all . push ( [ key , header [ key ] ] ) ;
43
+ }
35
44
}
36
45
return all ;
37
46
} ,
@@ -41,11 +50,11 @@ function generateResponse(res) {
41
50
} ;
42
51
}
43
52
44
- export default ( typeof fetch == 'function'
53
+ export default ( typeof fetch === 'function'
45
54
? fetch . bind ( )
46
55
: function ( url , options ) {
47
56
options = options || { } ;
48
- return http
57
+ return httpClient
49
58
. request ( options . method || 'get' , url , options . body , options . headers )
50
59
. then ( res => Promise . resolve ( generateResponse ( res ) ) )
51
60
. catch ( res => Promise . reject ( generateResponse ( res ) ) ) ;
You can’t perform that action at this time.
0 commit comments