export async function getUser(req, res) {
//res.json("Get User Route");
const { username } = req.params;
console.log("I am from getUserController", username);
try {
if (!username) return res.status(501).send({ error: "Invalid Username" });
UserModel.findOne({ username }, function (err, user) {
if (err) return res.status(500).send({ err });
if (!user)
return res.status(501).send({ error: "Couldn't Find the User" });
return res.status(201).send(user);
});
} catch (error) {
return res.status(404).send({ error: "Cannot Find User Data" });
}
}
/* GET: http://localhost:8080/api/user/example123 /
export async function getUser(req, res) { //res.json("Get User Route"); const { username } = req.params; console.log("I am from getUserController", username);
try { if (!username) return res.status(501).send({ error: "Invalid Username" }); UserModel.findOne({ username }, function (err, user) { if (err) return res.status(500).send({ err }); if (!user) return res.status(501).send({ error: "Couldn't Find the User" }); return res.status(201).send(user); }); } catch (error) { return res.status(404).send({ error: "Cannot Find User Data" }); } }