-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lab-khalid #8
base: master
Are you sure you want to change the base?
lab-khalid #8
Conversation
after( done => { | ||
if(this.tempEmployee){ | ||
Employee.deleteEmployee(this.tempEmployee.id) | ||
.then(done()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to return this function like you do for all the other CRUD operations.
No description provided.