File tree Expand file tree Collapse file tree
test/fixtures/output/node/request Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- var http = require ( "http" ) ;
1+ var request = require ( 'request' ) ;
22
33var options = {
4- "method" : "GET" ,
5- "hostname" : "mockbin.com" ,
6- "port" : null ,
7- "path" : "/har?key=value&baz=abc&foo=bar&foo=baz" ,
8- "headers" : { }
9- } ;
10-
11- var req = http . request ( options , function ( res ) {
12- var chunks = [ ] ;
13-
14- res . on ( "data" , function ( chunk ) {
15- chunks . push ( chunk ) ;
16- } ) ;
17-
18- res . on ( "end" , function ( ) {
19- var body = Buffer . concat ( chunks ) ;
20- } ) ;
4+ url : 'http://mockbin.com/har?key=value&baz=abc&foo=bar&foo=baz' ,
5+ headers : { }
6+ }
7+ request . get ( options , function ( error , response , body ) {
8+ if ( error ) {
9+ //throw error here
10+ return ;
11+ }
12+ // work with response and body here;
2113} ) ;
22-
23- req . end ( ) ;
Original file line number Diff line number Diff line change 1- var http = require ( "http" ) ;
2-
3- var options = {
4- "method" : "GET" ,
5- "hostname" : "mockbin.com" ,
6- "port" : null ,
7- "path" : "/har?" ,
8- "headers" : { }
9- } ;
10-
11- var req = http . request ( options , function ( res ) {
12- var chunks = [ ] ;
13-
14- res . on ( "data" , function ( chunk ) {
15- chunks . push ( chunk ) ;
16- } ) ;
17-
18- res . on ( "end" , function ( ) {
19- var body = Buffer . concat ( chunks ) ;
20- } ) ;
1+ var request = require ( 'request' ) ;
2+
3+ request . get ( 'http://mockbin.com/har?' , function ( error , response , body ) {
4+ if ( error ) {
5+ //throw error here
6+ return ;
7+ }
8+ // work with response and body here;
219} ) ;
22-
23- req . end ( ) ;
You can’t perform that action at this time.
0 commit comments