Skip to content

Instantly share code, notes, and snippets.

@M-Naveed-Ashraf
Forked from codecademydev/app.js
Last active November 18, 2021 13:12
Show Gist options
  • Select an option

  • Save M-Naveed-Ashraf/5f5914404055b953199b4ef8176882e9 to your computer and use it in GitHub Desktop.

Select an option

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
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