Skip to content

Commit 1d51c0c

Browse files
authored
Merge pull request #40 from fack2/Backend/Destination-page
Backend/destination page #38
2 parents 44eb08b + 8612740 commit 1d51c0c

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "An app used to book a flight ticket",
55
"main": "index.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"start": "node server/index.js",
8+
"server": "nodemon server/index.js"
89
},
910
"repository": {
1011
"type": "git",
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const getDestinationData = require('../database/queries/getDestinationData');
2+
3+
exports.getDestinationInfo = (req, res) => {
4+
getDestinationData()
5+
.then(data => {
6+
res.json(data.rows);
7+
})
8+
.catch(err => console.log(err));
9+
};

server/controllers/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
const express = require('express');
22
const router = express.Router();
33

4+
const { getDestinationInfo } = require('./getDestinationInfo');
5+
6+
router.get('/destination', getDestinationInfo);
7+
48

59
module.exports = router;
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
const dbConnection = require('./../db_connection');
22

3-
const getDestinationData = country => {
4-
return dbConnection.query('SELECT * FROM destination WHERE country = $1', [
5-
country
6-
]);
3+
const getDestinationData = () => {
4+
return dbConnection.query('SELECT * FROM destination');
75
};
86

97
module.exports = getDestinationData;

0 commit comments

Comments
 (0)