Building the front and back end of the Pokedex
When I started this project, I had no intention of adding a front end UI. The point was for the app to be usable from the command line, and I had no interest in building a web app. But then I saw an HTML template for the original design of the Pokedex and descided that it needed to be built.
const getByName = async (req, res, next) => {
const name = req.params.name
console.log(name)
const result = await mongodb
.getDb()
.db()
.collection('pokemon')
.find({ name: name })
const lists = await result.toArray()
res.setHeader('Content-Type', 'application/json')
const item = lists[0]
if (item) {
res.status(200).json(item)
} else {
res.sendStatus(404)
}
}