Conversation
| after( done => { | ||
| if(this.tempEmployee){ | ||
| Employee.deleteEmployee(this.tempEmployee.id) | ||
| .then(done()) |
There was a problem hiding this comment.
you are actually calling done multiple times here.
.then(done()) is not the same as .then( () => done()) and then below in your catch block you need to catch and err and pass that to done like you do your previous after blocks (i.e. .catch( err => done(err))
| debug('error-middleware'); | ||
| if(err.status){ | ||
| debug('User error'); | ||
| res.status(err.message).send(err.message); |
There was a problem hiding this comment.
you are incorrectly sending err.message back as the status and not the err.status. This is currently causing your error messages to fail with a 500 status because you are passing something that isn't a status but is actually a message.
|
|
||
| empRouter.put('/api/employee',jsonParser, function(req, res, next){ | ||
| debug('PUT /api/employee'); | ||
| Employee.updateEmployee(req.query.id, req.body) |
There was a problem hiding this comment.
this actually needs to be a params not a query.
| .catch(err => next(err)); | ||
| }); | ||
|
|
||
| empRouter.put('/api/employee',jsonParser, function(req, res, next){ |
There was a problem hiding this comment.
you need to pass a param into your put route (i.e. /api/employee/:id)
|
|
||
| Employee.updateEmployee = function(id, _employee){ | ||
| debug('updateEmployee'); | ||
| storage.fetchItem('employee', id) |
There was a problem hiding this comment.
You need to return this function like you do for all the other CRUD operations.
No description provided.