modify
This commit is contained in:
parent
04905b0d24
commit
c5f1fe7576
@ -70,25 +70,26 @@ export const createDirectory = async (req, res) => {
|
|||||||
export const getAllDirectory = async (req, res) => {
|
export const getAllDirectory = async (req, res) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (req.user.role === "admin") {
|
console.log("hi")
|
||||||
|
|
||||||
|
if (req.user && req.user.role === "admin") {
|
||||||
const directory = await directoryModel.find();
|
const directory = await directoryModel.find();
|
||||||
// console.log(category)
|
// console.log(category)
|
||||||
res.status(200).json({
|
return res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
msg: " fetch Successfully!!",
|
msg: " fetch Successfully!!",
|
||||||
directory,
|
directory,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
const directory = await directoryModel.find({ status: true });
|
const directory = await directoryModel.find({ status: true });
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
msg: " fetch Successfully!!",
|
msg: " fetch Successfully!!",
|
||||||
directory,
|
directory,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
res.status(500).json({
|
res.status(500).json({
|
||||||
success: false,
|
success: false,
|
||||||
msg: "Failled to fetch !!"
|
msg: "Failled to fetch !!"
|
||||||
|
Loading…
Reference in New Issue
Block a user