show error page when no search request is found

This commit is contained in:
Bilal Catic
2019-10-14 11:20:45 +02:00
parent 25ee3bc16c
commit e0a1444b55
2 changed files with 7 additions and 2 deletions

View File

@@ -66,7 +66,8 @@ const getQueryReview = async (req, res) => {
const searchRequest = await currentSearchRequest(req);
if (!searchRequest || !searchRequest.dataValues) {
return null;
res.render("notFound", { title: " " });
return;
}
const title = "Da li je ovo to što ste tražili ?";

View File

@@ -4,7 +4,11 @@ const sequelize = require("sequelize");
const Op = sequelize.Op;
const getSearchRequest = async searchRequestId => {
return await db.SearchRequest.findByPk(searchRequestId);
try {
return await db.SearchRequest.findByPk(searchRequestId);
} catch (error) {
return null;
}
};
const createSearchRequest = async (searchRequestFields = {}) => {