diff --git a/client/admin/brewLookup/brewLookup.jsx b/client/admin/brewLookup/brewLookup.jsx
index 427c05915..c9212d990 100644
--- a/client/admin/brewLookup/brewLookup.jsx
+++ b/client/admin/brewLookup/brewLookup.jsx
@@ -66,14 +66,6 @@ const BrewLookup = createClass({
'fa-spin fa-spinner' : this.state.searching,
})} />
-
-
-
{this.state.error
&&
{this.state.error.toString()}
diff --git a/server/admin.api.js b/server/admin.api.js
index 4835411d6..c0615de1b 100644
--- a/server/admin.api.js
+++ b/server/admin.api.js
@@ -55,22 +55,31 @@ router.post('/admin/cleanup', mw.adminOnly, (req, res)=>{
});
/* Searches for matching edit or share id, also attempts to partial match */
-router.get('/admin/lookup/:id', mw.adminOnly, (req, res, next)=>{
- HomebrewModel.findOne({ $or : [
- { editId: { '$regex': req.params.id, '$options': 'i' } },
- { shareId: { '$regex': req.params.id, '$options': 'i' } },
- ] }).exec((err, brew)=>{
- return res.json(brew);
- });
+
+router.get('/admin/lookup/:id', mw.adminOnly, async (req, res, next) => {
+ try {
+ const brew = await HomebrewModel.findOne({
+ $or: [
+ { editId: { $regex: req.params.id, $options: 'i' } },
+ { shareId: { $regex: req.params.id, $options: 'i' } },
+ ]
+ }).exec();
+
+ if (!brew) {
+ // No document found
+ return res.status(404).json({ error: 'Document not found' });
+ }
+
+ return res.json(brew);
+ } catch (error) {
+ console.error(error);
+ return res.status(500).json({ error: 'Internal Server Error' });
+ }
});
-/* Searches for matching title, also attempts to partial match */
-router.get('/admin/lookup/:id', mw.adminOnly, (req, res, next)=>{
- HomebrewModel.findOne({ $or : { title: { '$regex': /./, '$options': 'i' } } }).exec((err, brew)=>{
- return res.json(brew);
- });
-});
+
+
/* Find 50 brews that aren't compressed yet */
router.get('/admin/finduncompressed', mw.adminOnly, (req, res)=>{
uncompressedBrewQuery.exec((err, objs)=>{