backend/api/routes/accountRoute.js
2020-05-01 18:24:59 +02:00

19 lines
412 B
JavaScript

let express = require('express');
let router = express.Router();
let Account = require('../models/accountModel');
// Add a user
router.post('/', async (req, res) => {
const userData = { ...req.body };
try {
const user = await Account.addUser(userData);
res.status(201).json(user);
} catch (error) {
res.status(500).json({ message: 'Failed to add new user', error });
}
});
module.exports = router;