'Hello community! I have a problem, I want to create a controller in mongoDB that returns all the orders that a certain user makes in an ecommerce

This is the function: enter image description here

This is the error:
enter image description here

Although both collections are correctly related, and I know this because in the database, each order has its respective user as property, when making the GET request, it tells me that the user's id is undefined.

enter image description here

The route is fine, the relation of both collections is also, I don't know what the error is, please help, thank you very much in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source