mirror of
https://gitlab.com/nekoya/web.git
synced 2024-11-14 02:16:19 +01:00
Add error handler for product page
This commit is contained in:
parent
f209037436
commit
43e8497d67
1 changed files with 24 additions and 16 deletions
|
@ -180,14 +180,19 @@ router.get("/products", (req, res) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/product/:id", (req, res) => {
|
router.get(["/product", "/product/:id"], (req, res) => {
|
||||||
|
if (!req.params.id) {
|
||||||
auth.session_converter(req.cookies.session_token).then((key) => {
|
auth.session_converter(req.cookies.session_token).then((key) => {
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
controller.getProduct(req.params.id).then((data) => {
|
controller.getProduct(req.params.id).then((data) => {
|
||||||
|
if (data != undefined) {
|
||||||
res.render("pages/product", {
|
res.render("pages/product", {
|
||||||
data: data,
|
data: data,
|
||||||
loggedIn: 'true'
|
loggedIn: 'true'
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
res.redirect("/products");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
controller.getProduct(req.params.id).then((data) => {
|
controller.getProduct(req.params.id).then((data) => {
|
||||||
|
@ -198,6 +203,9 @@ router.get("/product/:id", (req, res) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
res.redirect("/products")
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/bag", (req, res) => {
|
router.get("/bag", (req, res) => {
|
||||||
|
|
Loading…
Reference in a new issue