Skip to content

Commit 0378928

Browse files
committed
tutorial complete
1 parent d92483a commit 0378928

File tree

4 files changed

+37
-19
lines changed

4 files changed

+37
-19
lines changed

app.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ app.use(
2020
app.get("/", (req, res) => {
2121
// Getting getAll function from the client
2222
client.getAll({}, (err, response) => {
23-
res.render("home", { details: response.message });
23+
if (!err) {
24+
res.render("home", { details: response.message });
25+
} else {
26+
console.log(err.details);
27+
}
2428
});
2529
});
2630

@@ -30,11 +34,16 @@ app.get("/:id", (req, res) => {
3034
this getDetails takes a id as parameter as we defined in the proto file then gives out a response needed.
3135
*/
3236
client.getDetails({ id: req.params.id }, (err, response) => {
33-
res.render("details", { details: response.message });
37+
if (!err) {
38+
res.render("details", { details: response.message });
39+
} else {
40+
console.log(err.details);
41+
}
3442
});
3543
});
3644

3745
const PORT = process.env.PORT || 3000;
46+
3847
app.listen(PORT, () => {
39-
console.log("Running on port " + PORT);
48+
console.log(`Process ${process.pid} Running on port ` + PORT);
4049
});

views/details.pug

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ html(lang="en")
55
meta(name="viewport", content="width=device-width, initial-scale=1.0")
66
title Details
77
body
8-
h3 email:
9-
email= details.email
10-
h3 first Name:
11-
fname= details.firstName
12-
h3 last Name:
13-
lname= details.lastName
8+
table(style="border:1px solid black; width:50%")
9+
tr
10+
th email
11+
th first Name
12+
th last Name
13+
tr
14+
td
15+
fname= details.firstName
16+
td
17+
lname= details.lastName
18+
td
19+
email= details.email

views/home.css

Lines changed: 0 additions & 3 deletions
This file was deleted.

views/home.pug

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ html(lang="en")
55
meta(name="viewport", content="width=device-width, initial-scale=1.0")
66
title Document
77
body
8-
each val in details
9-
h3 email:
10-
email= val.email
11-
h3 first Name:
12-
fname= val.firstName
13-
h3 last Name:
14-
lname= val.lastName
8+
table(style="border:1px solid black; width:50%")
9+
tr
10+
th email
11+
th first Name
12+
th last Name
13+
each val in details
14+
tr
15+
td
16+
fname= val.firstName
17+
td
18+
lname= val.lastName
19+
td
20+
email= val.email
1521

0 commit comments

Comments
 (0)