diff --git a/client/homebrew/pages/archivePage/archivePage.jsx b/client/homebrew/pages/archivePage/archivePage.jsx
index 31e2684b..9228d1a3 100644
--- a/client/homebrew/pages/archivePage/archivePage.jsx
+++ b/client/homebrew/pages/archivePage/archivePage.jsx
@@ -100,8 +100,8 @@ const ArchivePage = createClass({
if(update === true) {
this.updateStateWithForm();
};
-
- try {
+ if (title !== '') {
+ try {
this.setState({ searching: true, error: null });
const title = encodeURIComponent(this.state.title);
@@ -117,6 +117,12 @@ const ArchivePage = createClass({
this.setState({ error: `${error.response.status}` })
this.updateStateWithBrews([], 1, 1, 0);
}
+ console.log(!this.state.brewCollection || brewCollection.length === 0);
+ if(!this.state.brewCollection) {
+ this.setState({ error: '404'});
+ }
+ }
+
},
renderNavItems : function () {
@@ -253,8 +259,16 @@ const ArchivePage = createClass({
);
};
- if(title === '') {return (
Whenever you want, just start typing...
);}
+
+ if(title === '') {return (Whenever you want, just start typing...
);}
+ if (!brewCollection || brewCollection.length === 0) {
+ return (
+
+
No brews found
+
+ );
+ };
if (error) {
console.log('render Error: ', error);
let errorMessage;
@@ -277,13 +291,7 @@ const ArchivePage = createClass({
);
};
- if (!brewCollection || brewCollection.length === 0) {
- return (
-
-
No brews found
-
- );
- };
+
return (
diff --git a/server/archive.api.js b/server/archive.api.js
index a7f545e7..fffe2449 100644
--- a/server/archive.api.js
+++ b/server/archive.api.js
@@ -41,7 +41,7 @@ const archive = {
.maxTimeMS(5000)
.exec();
- const totalBrews = await HomebrewModel.countDocuments(titleQuery, projection);
+ const totalBrews = await HomebrewModel.countDocuments(titleQuery, projection).maxTimeMS(5000);
const totalPages = Math.ceil(totalBrews / pageSize);
//console.log('Total brews: ', totalBrews);
@@ -49,10 +49,6 @@ const archive = {
return res.json({ brews, page, totalPages, totalBrews});
} catch (error) {
console.error(error);
- console.log(error);
- if (error.response && error.response.status === 404) {
- return res.status(404).json({ errorCode: '404', message: 'Brews not found' });
- }
if (error.response && error.response.status === 503) {
return res.status(503).json({ errorCode: '503', message: 'Service Unavailable' });
} else {