React Client App

May 7, 2021 ยท View on GitHub

This project was bootstrapped with Create React App.

Project Structure

App.js

This is where all of our React components live. Notice the App component doesn't make API calls directly, but delegates that responsibility to the apiClient module.

apiClient.js

The functions in this module are responsible for talking to the Express API server.

We use the browser built-in fetch function to perform the HTTP communication.

Notice that we always translate the reponse from JSON to JavaScript object using the Body.json() method.

Adding Custom Environment Variables During Development

Sometimes you need to add dynamic variables into your app. See the Create React App documentation for more information on how to do this with a .env file in this directory.

Proxy the Express Server

See the Create React App documentation for an explanation of why we want to proxy our API server.