Skip to content

Commit

Permalink
Change response format to the one in README
Browse files Browse the repository at this point in the history
  • Loading branch information
Froilan Irizarry committed Apr 14, 2019
1 parent c058ffd commit 703985b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ router.get('/apagon', async (req, res, next) => {
const dbClient = await getApagonesDBClient();
const results = await dbClient.find();

res.json(results);
res.json({ data: results });
});


router.post('/apagon', async (req, res, next) => {
const dbClient = await getApagonesDBClient();
const data = req.body;
try {

const results = await dbClient.insert(data);
res.json(results);
res.json({ data: results });
} catch(error) {
console.error(error);
}
Expand All @@ -32,7 +33,7 @@ router.get('/lugar', async (req, res, next) => {
const dbClient = await getLugaresDBClient();
const results = await dbClient.find();

res.json(results);
res.json({ data: results });
});


Expand All @@ -41,7 +42,7 @@ router.post('/lugar', async (req, res, next) => {
const data = req.body;
try {
const results = await dbClient.insert(data);
res.json(results);
res.json({ data: results });
} catch (error) {
console.error(error);
}
Expand Down

0 comments on commit 703985b

Please sign in to comment.