REST
Last part, let's make Express answer with a list of people.
We now have two routes in our express app. /
leads to "ok", and /contacts/list
gives us a list of contacts.
Run the app, and try it; navigate to http://localhost:8080/contacts/list, and verify you see a list of people
Great! Moving on to linkage with the front-end now. We're almost done with our setup
PART II - Step 7: Access the Back-End from the Front-End
Let's go back to our front end. We need to be able to access this data.
In a first instance, let's keep it simple. We're simply going to query the back-end, and log the answer
Move into front/src
, open index.js
, and write in it, anywhere:
run the root npm start
, to start the back and front. Go to http://localhost:3000, and check the console. You should see the contacts in your log. Ok great!
Let's use that in React now. Remove the lines above, we don't need them anymore
Last updated
Was this helpful?