Skip to content

Commit

Permalink
fix: added catch statement and removed unresolved variable
Browse files Browse the repository at this point in the history
  • Loading branch information
varijkapil13 committed Jan 16, 2019
1 parent b76539d commit d3293d6
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions server/controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,38 +34,31 @@ class Users {
}
});
}

static signUp(req, res) {
const {email, password, roles, first_name, last_name} = req.body;
Avatar.create({
first_name,
last_name,
email
}).then(avatar => {
if (avatar) {
})
.then(avatar => {
return User.create({
email,
password,
avatarId: avatar.id,
roles
}).then(userData =>
res.status(201).send({
success: true,
message: 'User successfully created',
userData
})
);
} else {
return res.status(400).send({
status: false,
errors: [
{
name: 'No Avatar found',
details: 'Avatar with id ' + avatarId + ' was not found in the database'
}
]
});
}
});
})
.then(userData =>
res.status(201).send({
success: true,
message: 'User successfully created',
userData
})
)
.catch(error => res.status(400).send(error));
})
.catch(error => res.status(400).send(error));
}
}

Expand Down

0 comments on commit d3293d6

Please sign in to comment.