pricing update to db
This commit is contained in:
parent
5aae9ee8e0
commit
42598d6f20
|
@ -111,22 +111,22 @@ router.get("/", auth, async (req, res) => {
|
|||
});
|
||||
});
|
||||
router.put("/update", async (req, res) => {
|
||||
const { email,pricing } = req.body;
|
||||
const existingUser = await User.findOne({ email: email });
|
||||
const { id,pricing } = req.body;
|
||||
|
||||
|
||||
if (!existingUser) {
|
||||
console.log("id " + id)
|
||||
if (!id) {
|
||||
return res.status(400).json({ Msg: "Not all fields have been entered." });
|
||||
|
||||
}
|
||||
|
||||
User.findByIdAndUpdate({ _id: existingUser._id }, { pricing: pricing }).then(() => {
|
||||
User.findOne({ email: email }).then((user) => {
|
||||
User.findByIdAndUpdate(id, { pricing: pricing }).then(() => {
|
||||
User.findOne({ _id: id }).then((user) => {
|
||||
res.send(user);
|
||||
console.log(user)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue