Skip to content

Instantly share code, notes, and snippets.

@JustAyush
Created April 3, 2021 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JustAyush/7716d0ab1b2aef9d177a9d157b7a2978 to your computer and use it in GitHub Desktop.
Save JustAyush/7716d0ab1b2aef9d177a9d157b7a2978 to your computer and use it in GitHub Desktop.
const express = require('express');
const router = express.Router();
const userService = require('./user.services.js');
// Fetch Users
router.get('/', async (req, res) => {
communicationsService.fetch()
.then(data => {
httpResponse.successHandler(res, data);
})
.catch(error => {
httpResponse.errorHandler(res, error, "User Controller: Error fetching users");
})
});
// Fetch Users by userId
router.get('/:id', async (req, res) => {
const { id } = req.params;
communicationsService.fetchById(id)
.then(data => {
httpResponse.successHandler(res, data);
})
.catch(error => {
httpResponse.errorHandler(res, error, "User Controller: Error fetching user by userId");
})
});
module.exports = router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment