Hi,
Really loving Loopback and the community... but just can't crack this. Spent a few days in the docs and can't find anything obviously wrong...
If I call nestRemoting() on a model with the option hooks:false set, then things are fine.
Having to provide options isn't mentioned in the docs... so I guess this is masking a deeper problem?
If planet is the top-level model, which hasMany moon[s], which in-turn hasMany crater[s]...
And we've planet.nestRemoting('moons'), then posting to /api/planets, with the hooks:false option omitted, results in:
TypeError: Cannot read property 'moon' of undefined
at EventEmitter.<anonymous> (/home/tim/GithubProjects/nest-remoting-issue/node_modules/loopback/lib/model.js:809:58)
at EventEmitter.g (events.js:260:16)
at emitThree (events.js:97:13)
at EventEmitter.emit (events.js:175:7)
at /home/tim/GithubProjects/nest-remoting-issue/node_modules/loopback/lib/application.js:279:22
at Array.forEach (native)
at EventEmitter.app.handler (/home/tim/GithubProjects/nest-remoting-issue/node_modules/loopback/lib/application.js:278:21)
at /home/tim/GithubProjects/nest-remoting-issue/node_modules/loopback/server/middleware/rest.js:65:20
at /home/tim/GithubProjects/nest-remoting-issue/node_modules/loopback/server/middleware/rest.js:72:7
at iterate (/home/tim/GithubProjects/nest-remoting-issue/node_modules/async/lib/async.js:146:13)
Which seems to point to something not being quite right with the way our remotes are set-up? This is the line in Model.nestRemoting that fails:
var beforeListeners = remotes.listenerTree.before[toModelName] || {};
- ...because
remotes.listenerTree is an empty object with no before key.
- I've made a repo to replicate this issue here.
- And this might be a clue: once that first post fails, any subsequent posts to the same endpoint work just fine!
I guess I'm doing something stupid/in the wrong order/wrong timing when booting, but just can't find it.
We would really appreciate some assistance as this is (hopefully) the last snag before we commit to Loopback in our next project.
Thanks in advance, keep up the great work!
Tim
Hi,
Really loving Loopback and the community... but just can't crack this. Spent a few days in the docs and can't find anything obviously wrong...
If I call
nestRemoting()on a model with the optionhooks:falseset, then things are fine.Having to provide options isn't mentioned in the docs... so I guess this is masking a deeper problem?
If planet is the top-level model, which
hasManymoon[s], which in-turnhasManycrater[s]...And we've
planet.nestRemoting('moons'), then posting to/api/planets, with thehooks:falseoption omitted, results in:Which seems to point to something not being quite right with the way our remotes are set-up? This is the line in
Model.nestRemotingthat fails:var beforeListeners = remotes.listenerTree.before[toModelName] || {};remotes.listenerTreeis an empty object with nobeforekey.I guess I'm doing something stupid/in the wrong order/wrong timing when booting, but just can't find it.
We would really appreciate some assistance as this is (hopefully) the last snag before we commit to Loopback in our next project.
Thanks in advance, keep up the great work!
Tim