DEV Community

Discussion on: Complete REST API with diskdb, Node, and Express in 5 minutes

Collapse
 
sebring profile image
J. G. Sebring

Thanks, this was very handy as a dev db for demos or when backend are slacking, hehe.

I use this and added collection as a parameter.

server.get('/:collection/:id', (req, res) => {
  const collection = req.params.collection
  const id = req.params.id
  const item = db[collection].find({id})
  // validate
  res.json(item)
}