File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -17,13 +17,28 @@ const app = express();
1717// Application
1818app . get ( '/' , function ( req , res ) {
1919 if ( process . env . NODE_ENV === 'development' ) {
20- for ( var key in require . cache ) {
21- delete require . cache [ key ] ;
22- }
20+ // This doesn't work in ESM mode.
21+ // for (var key in require.cache) {
22+ // delete require.cache[key];
23+ // }
2324 }
2425 require ( './handler.server.js' ) ( req , res ) ;
2526} ) ;
2627
28+ app . get ( '/todos' , function ( req , res ) {
29+ res . setHeader ( 'Access-Control-Allow-Origin' , '*' ) ;
30+ res . json ( [
31+ {
32+ id : 1 ,
33+ text : 'Shave yaks' ,
34+ } ,
35+ {
36+ id : 2 ,
37+ text : 'Eat kale' ,
38+ } ,
39+ ] ) ;
40+ } ) ;
41+
2742app . listen ( 3001 , ( ) => {
2843 console . log ( 'Flight Server listening on port 3001...' ) ;
2944} ) ;
Original file line number Diff line number Diff line change 11import * as React from 'react' ;
2+ import { fetch } from 'react-fetch' ;
23
34import Container from './Container.js' ;
45
@@ -8,11 +9,17 @@ import {Counter as Counter2} from './Counter2.client.js';
89import ShowMore from './ShowMore.client.js' ;
910
1011export default function App ( ) {
12+ const todos = fetch ( 'http://localhost:3001/todos' ) . json ( ) ;
1113 return (
1214 < Container >
1315 < h1 > Hello, world</ h1 >
1416 < Counter />
1517 < Counter2 />
18+ < ul >
19+ { todos . map ( todo => (
20+ < li key = { todo . id } > { todo . text } </ li >
21+ ) ) }
22+ </ ul >
1623 < ShowMore >
1724 < p > Lorem ipsum</ p >
1825 </ ShowMore >
You can’t perform that action at this time.
0 commit comments