You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But if the entity is null, then the return of the merge (the updated variable) will not be a Mongoose doc. Then, when updated.save() is called, it will throw a save is a not a function of null error. To fix, saveUpdates should be wrapped in an if statement:
In the promise chain:
If the entity is not found,
handleEntityNotFound
passes null tosaveUpdates
.But if the entity is null, then the return of the merge (the
updated
variable) will not be a Mongoose doc. Then, whenupdated.save()
is called, it will throw asave is a not a function of null
error. To fix, saveUpdates should be wrapped in an if statement:The text was updated successfully, but these errors were encountered: