When I try to create a user in the database by calling the function createOne
inside createProfile
, it seems like the function is not getting executed. Even though the route is functioning properly, I'm facing an issue with calling a function within another function.
I could really use some assistance here!
exports.createOne = Model =>
catchAsync(async (req, res, next) => {
console.log("I am in createone")
const doc = await Model.create(req.body);
res.status(201).json({
status: 'success',
data: {
data: doc
}
});
});
exports.createProfile = (req,res) => {
console.log(req.query.segment);
if(req.query.segment == "Tour"){
let Segment = Tour;
console.log(factory);
factory.createOne(Tour);
}
}
Upon checking the console log results below, it appears that the function is not being triggered at all.
Tour
{ getOne: [Function], createOne: [Function] }
POST /api/v1/midasCommon/?segment=Tour - - ms - -