I use routing setup which uses the Dior structure of my 'API' folder to install routes However, in such cases where I use a folder name to represent the parameters of a path, the req.params is undefined in the controller.
The route with the problem is:
GET / Api / google / accounts /: account_id / analytics / profiles /
here My path is loader. It is basically a globe on the API folder that is looking for files named The 'API' folder structure is: In the above loop, route debug debug Is a wrapper around Npim package. Output is: So we can see that the path in question is being relatively established but req.params are undefined. Other problems do not require this problem. Why rake.Param is empty only for this special route? Is it better to have these nested routes made by using the folder as a way of the ultimate? EDIT: I hope this problem arises from nested router which is not able to reach the parameters of parents' router. routes.js
and app.use > on the proper path (determined by folder structure) Code> does.
// Load Router Files = glob.sync ("api / ** / routes.js"); Console.log (files); // ['API / Campaign / route. Js ', //' api / google / accounts :: account_ id / analytics / profiles / routes. JS ', //' API / Google / Accounts / Routes. Js ', //' api / google / url / routes JS ', //' API / Users / Routers JS '] // Use each router for the appropriate path (var i = 0; i & lt; files.length; i ++) {route = "/" + files [i] .split ("/ routes .js ") [0]; Console.log (route); // '/ api / google / accounts /: account_id / analytics / profile' router = is required (path.join (__dirname, files [i])) (config); Route = router.stack; App.use (root, router); // List all routes for this router (var j = 0; j & lt; routes.length; j ++) {routeDebug (("" + Object.keys (routes [j] .oot.methods] [ 0]. Toucherace ()). Piece (-6) + "+ + + route + route [J] root. Path); }}
./ api ./api/campaigns ./api/campaigns/controller.js//iPi / Campaign / model.js/api/campaigns/routes.js/api/users/api/users/controller.js/api/users/model.js ./api/users/routes.js// API / Google ./api/google/accounts ./api/google/accounts/:account_id ./api/google/accounts/:account_id/analytics ./api/google/accounts/:account_id/analytics/profiles//api/ Google / Accounts /: account_id / analytics / profile / administrator.js/api/google/accounts/:account_id/analytics/profiles/routes.js//api/google/accounts/controller.js/api/google/accounts/ Model.js ./api/google/accounts/routes.js ./api/google/urls//api/google/urls/controller.js//api/google/urls/routes.js
Get Route / API / Campaign / + 0ms routes Post / API / Campaign / +2ms Roots Received / API / Campaign:: Campaign_ID + 1ms routes PUT / API / Campaign / : Remove Campaign_id + 0ms routes / API / Campaign: Campaign_ID + 0ms routes / API / google / accounts /: account_id / analytics / profiles / + 128ms routes / API / google / accounts / + 4ms routes post / API / google / accounts / + 0ms routes POST / API / Google / URL / +3ms Receive routes / API / User / + 12 MMS routes POST / API / User / + 0 MS Accessed / API / User :: User_ID + 0 MMS routes / YouTube / YouTube / UserUid / 0ms routes DELETE / api / users /: user_id + 0ms
< / Pre>
However, merge: truth}); // no difference
it has been detected; My project was still 4.2.0 on updating 4.5.0 and solving the problem to pass the {mergeParams: true}
child router. See this same question for more details:
No comments:
Post a Comment