Closed SharpBCD closed 4 years ago
Please share the actual error message and a full example of the service call.
Here is the code, it is in a hook in before-find and get
const query = context.params.query;
query.$eager = 'address';
context.params.query = query;
The error is:
GeneralError {type: "FeathersError", name: "GeneralError", message: "Cannot read property 'get' of undefined", code: 500, className: "general-error", …}
type: "FeathersError"
name: "GeneralError"
message: "Cannot read property 'get' of undefined"
code: 500
className: "general-error"
data: undefined
errors: {}
hook: {type: "before", arguments: Array(0), service: {…}, app: {…}, method: "find", …}
stack: "GeneralError: Cannot read property 'get' of undefined↵ at new GeneralError (webpack-internal:///./node_modules/@feathersjs/errors/lib/index.js:170:17)↵ at Object.convert (webpack-internal:///./node_modules/@feathersjs/errors/lib/index.js:239:7)↵ at Socket.eval (webpack-internal:///./node_modules/@feathersjs/transport-commons/lib/client.js:67:34)↵ at Socket.onack (webpack-internal:///./node_modules/socket.io-client/lib/socket.js:319:9)↵ at Socket.onpacket (webpack-internal:///./node_modules/socket.io-client/lib/socket.js:244:12)↵ at Manager.eval (webpack-internal:///./node_modules/component-bind/index.js:21:15)↵ at Manager.Emitter.emit (webpack-internal:///./node_modules/component-emitter/index.js:133:20)↵ at Manager.ondecoded (webpack-internal:///./node_modules/socket.io-client/lib/manager.js:345:8)↵ at Decoder.eval (webpack-internal:///./node_modules/component-bind/index.js:21:15)↵ at Decoder.Emitter.emit (webpack-internal:///./node_modules/component-emitter/index.js:133:20)"
__proto__: FeathersError
I see in the error stack that socket.io-client is used in your test, so you're probably testing this with a client.
For testing purposes, you can try to call the service internally in the server and see if it works.
Your error message could be thrown before even reaching the hook. you can debug and see if the hook is actually executed.
My guess is that this error has nothing to do with feathers-objection. it looks like an error you would get if a service doesn't exists, e.g. not loaded, or if you're are calling a service by name with a typo or missing something, like API version prefix.
You may be right. I did not had the export class declaration as in your example. Tried to modify it but I got an babel error but that's not an objections error. Meanwhile I solve it with another approach, may surf back to it later. Thanks for support.
most probably I do something wrong. I have a table
customers
and one withaddress
.query = { '$eager': 'address' }
or{ '$joinRelation': 'address' }
returns the error. Note: bellow code works:here is my customers.model:
so what do I do wrong?