1- const got = require ( 'got' ) ;
1+ const request = require ( 'request-promise-native' ) ;
2+ const url = require ( 'url' ) ;
23const async = require ( 'async' ) ;
3- const querystring = require ( 'querystring' ) ;
44
55/**
66 * base model
@@ -18,6 +18,7 @@ class base {
1818
1919 this . _perPage = this . config ? this . config . get ( '_perPage' ) : 100 ;
2020 this . _parallel = this . config ? this . config . get ( '_parallel' ) : 4 ;
21+ this . _proxy = this . config && this . config . get ( 'proxy' ) ? this . config . get ( 'proxy' ) : undefined ;
2122 }
2223
2324 /**
@@ -29,10 +30,11 @@ class base {
2930 post ( path , data ) {
3031 data . private_token = this . token ;
3132
32- return got ( `${ this . url } ${ path } ` , {
33- query : querystring . stringify ( data ) ,
34- method : 'POST' ,
33+ return request . post ( `${ this . url } ${ path } ` , {
3534 json : true ,
35+ body : data ,
36+ proxy : this . _proxy ,
37+ resolveWithFullResponse : true ,
3638 headers : {
3739 'PRIVATE-TOKEN' : this . token
3840 }
@@ -50,8 +52,10 @@ class base {
5052 path += ( path . includes ( '?' ) ? '&' : '?' ) + `private_token=${ this . token } ` ;
5153 path += `&page=${ page } &per_page=${ perPage } ` ;
5254
53- return got ( `${ this . url } ${ path } ` , {
55+ return request ( `${ this . url } ${ path } ` , {
5456 json : true ,
57+ proxy : this . _proxy ,
58+ resolveWithFullResponse : true ,
5559 headers : {
5660 'PRIVATE-TOKEN' : this . token
5761 }
0 commit comments