Express middleware passing variable, error 'TypeError: Cannot destructure property' in middleware function but works via route definiton
问题 I am using pug templates in express and have a layout which has my top navigation toolbar etc. Inside this layout (viewable on all routes) I want to include a count of some items in the toolbar (without having to include the request for each pages/route definition ideally). So I thought I should use middleware. I am able to use the response userProfile anywhere on the page in the /user view eg but when I try to add the const {_raw, _json, ...userProfile} = req.user; to the middleware I get