From f9711de634b6af758a8e18a003e2eab4058b63fb Mon Sep 17 00:00:00 2001 From: Charlie Humphreys Date: Wed, 16 Nov 2022 22:32:50 -0600 Subject: [PATCH] add elvis for the possibility that the save failed --- server/homebrew.api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index 44b604bbc..563926f01 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -251,7 +251,7 @@ const updateBrew = async (req, res)=>{ if(!brew._id) { // if the brew does not have a stub id, create and save it, then write the new value back to the brew. saved = await new HomebrewModel(brew).save().catch(saveError); - brew = saved.toObject(); + brew = saved?.toObject(); } else { // if the brew does have a stub id, update it using the stub id as the key. saved = await HomebrewModel.updateOne({ _id: brew._id }, brew).catch(saveError);