File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ const http = require ( 'http' ) ;
2+
3+ const request = http . get ( 'http://httpbin.org/get' , ( response ) => {
4+ response . on ( 'data' , ( data ) => {
5+ console . log ( data . toString ( ) ) ;
6+ } ) ;
7+ } ) ;
8+
9+ request . end ( ) ;
Original file line number Diff line number Diff line change 1+ const http = require ( 'http' ) ;
2+
3+ const url = 'http://httpbin.org/get' ;
4+ const options = {
5+ auth : 'myuser:mypass' ,
6+ headers : {
7+ Test : 'Some Value'
8+ }
9+ } ;
10+
11+ const request = http . get ( url , options , ( response ) => {
12+ response . on ( 'data' , ( data ) => {
13+ console . log ( data . toString ( ) ) ;
14+ } ) ;
15+ } ) ;
16+
17+ request . end ( ) ;
Original file line number Diff line number Diff line change 1+ const http = require ( 'http' ) ;
2+
3+ const url = 'http://httpbin.org/post' ;
4+ const options = {
5+ method : 'POST' ,
6+ } ;
7+
8+ const request = http . request ( url , options , ( response ) => {
9+ response . on ( 'data' , ( data ) => {
10+ console . log ( data . toString ( ) ) ;
11+ } ) ;
12+ } ) ;
13+
14+ request . write ( 'Hello world.' ) ;
15+ request . end ( ) ;
You can’t perform that action at this time.
0 commit comments