I have this alias middleware which supposed to manually initialized the queries.
exports.aliasTopTours = (req, res, next) => {
req.query.limit = '5';
req.query.sort = '-ratingsAverage,price';
req.query.fields = 'name,price,ratingsAverage,summary,difficulty';
next();
};
The problem is the req.query. I get an empty object instead of an object with the set fields in it. I'm not sure why is it doing it it's really puzzling.
req.queryis empty and how that code block relates to the middleware code you wrote here.req.query = Object.assign({limit: "5"}, req.query)as Middleware.