Skip to content

Commit

Permalink
edit get projects route
Browse files Browse the repository at this point in the history
relates #12
  • Loading branch information
rehabas committed Mar 31, 2020
1 parent 7dbac7f commit 31db520
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions server/controllers/routes/user/project/getProjectsData.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ const {
getProjects,
} = require('../../../../database/queries/project/getProjects');

const getProjectsData = (req, res, next) => {
getProjects()
.then(({ rows }) =>
res.json({
StatusCode: 200,
data: rows,
}),
)
.catch((err) => next(err));
const getProjectsData = async (req, res, next) => {
try {
const { rows } = await getProjects();
res.json({
StatusCode: 200,
data: rows,
});
} catch (err) {
next(err);
}
};

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ test('Get projects route', (done) => {
.expect(200)
.expect('Content-Type', /json/)
.end(async (err, res) => {
const { data } = res.body;
if (err) return done(err);
const { data } = res.body;
expect(data).toHaveLength(2);
done();
});
Expand Down

0 comments on commit 31db520

Please sign in to comment.