-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove default error messsage
- Loading branch information
1 parent
713ca5b
commit 3a44d25
Showing
2 changed files
with
28 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,34 @@ const Users = require("../models/users"); | |
|
||
exports.getUser = async function (req, res, next) { | ||
try { | ||
const currUser = await Users.findOne({ email: "[email protected]" }) | ||
.populate("favorites") | ||
.exec(); | ||
const currUser = await Users.findOne({ | ||
email: "[email protected]", | ||
}).exec(); | ||
|
||
res.status(200).json(currUser); | ||
} catch (error) { | ||
return next(error); | ||
next(error); | ||
} | ||
}; | ||
|
||
exports.updateUser = async function (req, res, next) { | ||
try { | ||
const { objectId, favorites } = req.body; | ||
const updatedUser = await Users.updateOne( | ||
{ _id: objectId }, | ||
{ $set: { favorites: favorites } } | ||
); | ||
|
||
if (updatedUser.acknowledged) { | ||
res.status(200).json(updatedUser); | ||
} else { | ||
const error = new Error( | ||
"Something went wrong while saving your favorites!" | ||
); | ||
error.status = 404; | ||
return next(error); | ||
} | ||
} catch (error) { | ||
next(error); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters