Skip to content

lab-khalid#8

Open
khalidM3 wants to merge 1 commit intocodefellows-javascript-401d13:masterfrom
khalidM3:master
Open

lab-khalid#8
khalidM3 wants to merge 1 commit intocodefellows-javascript-401d13:masterfrom
khalidM3:master

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