Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

khalidM3
Copy link

@khalidM3 khalidM3 commented Mar 1, 2017

No description provided.

after( done => {
if(this.tempEmployee){
Employee.deleteEmployee(this.tempEmployee.id)
.then(done())

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);

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)

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){

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)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants