File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 1
1
const fetch = require ( 'cross-fetch' )
2
2
3
- fetch ( 'https ://api.github.com/users/lquixada ' )
3
+ fetch ( 'http ://127.0.0.1:6000 ' )
4
4
. then ( res => {
5
5
if ( res . status >= 400 ) {
6
6
throw new Error ( 'Bad response from server' )
7
7
}
8
8
return res . json ( )
9
9
} )
10
- . then ( user => {
11
- console . log ( user )
10
+ . then ( data => {
11
+ console . log ( data )
12
12
} )
13
13
. catch ( err => {
14
14
console . error ( err )
Original file line number Diff line number Diff line change 6
6
"start" : " node dist/bundle"
7
7
},
8
8
"dependencies" : {
9
- "cross-fetch" : " * "
9
+ "cross-fetch" : " 4.0.0 "
10
10
}
11
11
}
Original file line number Diff line number Diff line change
1
+ const http = require ( 'http' )
2
+
3
+ const hostname = '127.0.0.1'
4
+ const port = 6000
5
+
6
+ const server = http . createServer ( ( req , res ) => {
7
+ res . statusCode = 200
8
+ res . setHeader ( 'Content-Type' , 'application/json' )
9
+ res . end ( JSON . stringify ( { foo : 1 } ) )
10
+ } )
11
+
12
+ server . listen ( port , hostname , ( ) => {
13
+ console . log ( `Server running at http://${ hostname } :${ port } /` )
14
+ } )
You can’t perform that action at this time.
0 commit comments