hiteshchoudhary / chai-backend

A video series on chai aur code youtube channel
5.36k stars 802 forks source link

getallvideos in video controller question #89

Open mohitthakur9901 opened 9 months ago

mohitthakur9901 commented 9 months ago

const getAllVideos = asyncHandler(async (req, res) => { const { page = 1, limit = 10, query, sortBy, sortType, userId } = req.query })

for what purpose we are using query parameter in req.query ?

anikettiwarime commented 9 months ago

The req.query object in Express.js is used to retrieve query parameters from the URL. These parameters are typically used for filtering, sorting, or pagination purposes when querying a database or fetching data from an external API. In the given code snippet, req.query is used to extract parameters such as page, limit, query, sortBy, sortType, and userId to customize the retrieval of videos, likely from a database or another data source.

mohitthakur9901 commented 9 months ago

Thank you very much now I understand 👍