Skip to content

Instantly share code, notes, and snippets.

@chalu
Last active September 28, 2017 12:44
Show Gist options
  • Save chalu/734d920902042a9775067f918638098b to your computer and use it in GitHub Desktop.
Save chalu/734d920902042a9775067f918638098b to your computer and use it in GitHub Desktop.
Sample use of dummy in-memory data with an Express API endpoint
// Generate similar data from https://www.generatedata.com/
const dummyData = {
developers: [
{
"id": "870D1B3F-9259-99A7-F18E-18CA40B3B284",
"name": "Heather Bullock",
"experience": 12,
"stack": "iOS"
},
{
"id": "77AF49F3-89CB-FBC1-22E8-5FDAA07B0EB4",
"name": "Chandler Winters",
"experience": 12,
"stack": "DevOps"
},
{
"id": "25D1AA1D-1FA7-7C1E-C1EB-A15A97C776B9",
"name": "Deacon Rios",
"experience": 14,
"stack": "VR"
},
{
"id": "DFC9803A-1655-97F7-B90B-A7052D432304",
"name": "Chanda Glenn",
"experience": 20,
"stack": "IoT"
}
]
};
let express = require('express');
let api = express();
// send necessary data to client on request
api.get('/devs', (req, res) => {
return res.json(dummyData.developers);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment