-
-
Save M-Naveed-Ashraf/5f5914404055b953199b4ef8176882e9 to your computer and use it in GitHub Desktop.
Codecademy export .... GET API request for one document from collection of documents ... express practice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const app = express(); | |
| const PORT = process.env.PORT || 4001; | |
| const buildingMaterials = { | |
| wood: ['plywood', '2x4s', 'cedar shingles'], | |
| metal: ['steel girders', 'wall studs', 'rebar'], | |
| }; | |
| app.listen(PORT, () => { | |
| console.log(`Server is listening on port ${PORT}`); | |
| }); | |
| app.get('/metals', (req, res, next) => { | |
| const arrayToSend = buildingMaterials.metal; | |
| res.send(arrayToSend); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment