File tree Expand file tree Collapse file tree 5 files changed +13
-13
lines changed
Expand file tree Collapse file tree 5 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ const http = require('http');
44
55const url = 'http://ietf.org/' ;
66
7- http . get ( url , res => {
7+ http . get ( url , ( res ) => {
88 console . log ( res . req . _header ) ;
99 console . dir ( res . headers ) ;
1010 if ( res . statusCode !== 200 ) {
@@ -14,7 +14,7 @@ http.get(url, res => {
1414 }
1515 res . setEncoding ( 'utf8' ) ;
1616 const buffer = [ ] ;
17- res . on ( 'data' , chunk => {
17+ res . on ( 'data' , ( chunk ) => {
1818 buffer . push ( chunk ) ;
1919 } ) ;
2020 res . on ( 'end' , ( ) => {
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ const fs = require('fs');
55
66const url = 'https://ietf.org/' ;
77
8- https . get ( url , res => {
8+ https . get ( url , ( res ) => {
99 console . log ( res . req . _header ) ;
1010 console . dir ( res . headers ) ;
1111 if ( res . statusCode !== 200 ) {
@@ -15,7 +15,7 @@ https.get(url, res => {
1515 }
1616 res . setEncoding ( 'utf8' ) ;
1717 const buffer = [ ] ;
18- res . on ( 'data' , chunk => {
18+ res . on ( 'data' , ( chunk ) => {
1919 buffer . push ( chunk ) ;
2020 } ) ;
2121 res . on ( 'end' , ( ) => {
Original file line number Diff line number Diff line change 33const http = require ( 'http' ) ;
44const https = require ( 'https' ) ;
55
6- const fetch = url => new Promise ( ( resolve , reject ) => {
6+ const fetch = ( url ) => new Promise ( ( resolve , reject ) => {
77 const protocol = url . startsWith ( 'https' ) ? https : http ;
8- protocol . get ( url , res => {
8+ protocol . get ( url , ( res ) => {
99 if ( res . statusCode !== 200 ) {
1010 const { statusCode, statusMessage } = res ;
1111 reject ( new Error ( `Status Code: ${ statusCode } ${ statusMessage } ` ) ) ;
1212 }
1313 res . setEncoding ( 'utf8' ) ;
1414 const buffer = [ ] ;
15- res . on ( 'data' , chunk => buffer . push ( chunk ) ) ;
15+ res . on ( 'data' , ( chunk ) => buffer . push ( chunk ) ) ;
1616 res . on ( 'end' , ( ) => resolve ( buffer . join ( ) ) ) ;
1717 } ) ;
1818} ) ;
1919
2020// Usage
2121
2222fetch ( 'http://ietf.org/' )
23- . then ( body => console . log ( body ) )
24- . catch ( err => console . error ( err ) ) ;
23+ . then ( ( body ) => console . log ( body ) )
24+ . catch ( ( err ) => console . error ( err ) ) ;
Original file line number Diff line number Diff line change @@ -9,13 +9,13 @@ const ajax = (base, methods) => {
99 const callback = args . pop ( ) ;
1010 const url = base + method + '/' + args . join ( '/' ) ;
1111 console . log ( url ) ;
12- http . get ( url , res => {
12+ http . get ( url , ( res ) => {
1313 if ( res . statusCode !== 200 ) {
1414 callback ( new Error ( `Status Code: ${ res . statusCode } ` ) ) ;
1515 return ;
1616 }
1717 const buffer = [ ] ;
18- res . on ( 'data' , chunk => buffer . push ( chunk ) ) ;
18+ res . on ( 'data' , ( chunk ) => buffer . push ( chunk ) ) ;
1919 res . on ( 'end' , ( ) => callback ( null , JSON . parse ( buffer . join ( ) ) ) ) ;
2020 } ) ;
2121 } ;
Original file line number Diff line number Diff line change @@ -8,8 +8,8 @@ const users = {
88} ;
99
1010const routing = {
11- '/api/user' : name => users [ name ] ,
12- '/api/userBorn' : name => users [ name ] . born
11+ '/api/user' : ( name ) => users [ name ] ,
12+ '/api/userBorn' : ( name ) => users [ name ] . born
1313} ;
1414
1515http . createServer ( ( req , res ) => {
You can’t perform that action at this time.
0 commit comments