Skip to content
Snippets Groups Projects
Commit 1c453159 authored by Ashwanth K's avatar Ashwanth K
Browse files

Upload New File

parent 9a3b9a0b
No related branches found
No related tags found
No related merge requests found
const router = require('express').Router();
let Admin = require('../model/admin.model');
router.route('/').get((req, res) => {
Admin.find()
.then(Admins => res.json(Admins))
.catch(err => res.status(400).json('Error: ' + err));
});
router.route('/add').post((req, res) => {
const admin_id = req.body.admin_id;
const name = req.body.name;
const email = req.body.email;
const password = req.body.password;
const newAdmin = new Admin({_id: admin_id,name,email,password});
newAdmin.save()
.then(() => res.json('Admin added!'))
.catch(err => res.status(400).json('Error: ' + err));
});
router.route('/:id').get((req, res) => {
Admin.findById(req.params.id)
.then(Admins => res.json(Admins))
.catch(err => res.status(400).json('Error: ' + err));
});
module.exports = router;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment