Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static async getPokemon(req, res) {
- // Get the id from the request params
- const { id } = req.params;
- // Destructure actions
- const {
- get,
- found,
- } = actions;
- // Destructure errors
- const {
- notFound,
- } = errors;
- // Get the pokemon through the Module
- const pokemon = await PokemonModule.find(id);
- log(get(id));
- if (pokemon) {
- // If a pokemon was founded it will be returned
- log(found(pokemon));
- res.send({ pokemon });
- } else {
- // if error throw an error
- res.status(404).send({ error: notFound(id) });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement