The server of EveryPlantSelectionApp is responsible for retrieving the plant names (the plant families, genuses, and species) and making them available to our client-side code via a simple REST API. To do this, we can use the express Node.js library, which enables us to route HTTP requests to specific functions, easily delivering JSON to our client.
Here's the skeletal beginnings of our server implementation:
import express from 'express';const app = express();const port = process.env.PORT || 3000;app.get('/plants/:query', (req, res) => { req.params.query; // => The query res.json({ fakeData: 'We can later place some real data here...' });});app.listen( port, () => console.log(`App listening on port ${port}!`));
As ...