Skip to content

Commit

Permalink
Call dbQueries getShopCoord function in home.js and give hbs the coor…
Browse files Browse the repository at this point in the history
…dinate object - ref #51
  • Loading branch information
macintoshhelper committed May 3, 2017
1 parent 28c91ff commit 739d1de
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/routes/home.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
const url = require('url');
const dbQueries = require('../dbQueries.js');

const handler = (request, reply) => {
const parsedUrl = url.parse(request.url);
if (parsedUrl.query.ajax) reply.view('index', {}, { layout: 'spa' });
else reply.view('index');
dbQueries.getShopCoordinates(1, (err, res) => {
if (err) {
console.log(err);
return;
}

const data = {
shopCoordinates: JSON.stringify(res.rows[0]),
};

const parsedUrl = url.parse(request.url);
if (parsedUrl.query.ajax) reply.view('index', data, { layout: 'spa' });
else reply.view('index', data);
});
};

module.exports = {
Expand Down

0 comments on commit 739d1de

Please sign in to comment.