Created
April 3, 2021 09:42
-
-
Save JustAyush/7716d0ab1b2aef9d177a9d157b7a2978 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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