-
Notifications
You must be signed in to change notification settings - Fork 118
TypeError: Cannot read property 'service' of undefined #56
Comments
You've mounted your user service at
|
Should I set Thank you |
Yeah, the That top line in the stack trace
Is this:
So for some reason this.app isn't set correctly in that service. |
I'd recommend trying to use the default |
Hmm. I'll look at that issue but ya you shouldn't be using the root '/' for a service. Services are meant to be descriptive anyway. |
Thanks. I tried to use the default |
if you are using |
I'll try running your gist. See if there is something else going on. |
@ekryski Thanks a lot 👍 I think that gist should work after modifying the userEndpoint. |
no problem. I think that may be your issue. Report back. We recently added some docs on routing. http://docs.feathersjs.com/middleware/routing.html |
if I will post login request to
What should the userEndPoint be? |
@wuyuanyi135 ah ok you are mounting a sub-app. I haven't tried that with auth yet. I think |
Another thing I noticed in your gist is that all the hooks now take an userService.before(
{
create: [authHooks.hashPassword('password')]
}
) to this: userService.before(
{
create: [authHooks.hashPassword({ passwordField: 'password'})]
}
) or you could just pass nothing since |
@wuyuanyi135 I just pushed a working sub-app example. Hopefully that helps. |
I think the reason |
@ekryski Thanks for your example. I have figured out the reason of this issue. It was improper configuration of the sub-apps. I left out these lines in my var app = feathers()
.configure(socketio())
.configure(rest())
.use(bodyParser.json())
.use(bodyParser.urlencoded({extended: true})); Even though there is no explicit use of feathers services, the intermediate router app: var feathers = require('feathers');
var app = feathers();
var user = require('./user');
app.use('/user',user); won't work. Basically, all the sub-apps have to be configured like this to relay the request to deeper level. |
@wuyuanyi135 ya you are right. We should probably try and toss up some better error messaging or warnings. Thanks for that feedback! The issue is actually related this one: feathersjs/feathers#216. When we close that you shouldn't ever run into this problem. |
I've been having this issue for a few weeks too and it's super frustrating. My setup is relatively simple too:
What's weird is that if I make a call to I did some more digging and in both cases, on the local setup, |
@startupthekid how did you configure the parent app? |
Very simply:
I believe I just found the error inside the local service but I'll need a few minutes to verify. |
Ok yeah I fixed it. @ekryski in the default export of the local service (and maybe others, I'm not sure):
you have to add It had nothing to do with it being a sub-app as far as I can tell, everything to do with the service being an es6 based class. |
@startupthekid if you are using sub-apps, are you calling |
ES6 classes work the same way as normal services so that should not be an issue. But |
Ah I see, the call to |
It does call feathersjs/feathers#232 and feathersjs/feathers#216 are probably related to this. |
ok then we should probably call setup when rest is configured as well. I've created an issue for this: feathersjs/feathers#259 |
Believe it or not, I'm having this problem too. And I don't have my API mounted as a subapp. I have no idea how to fix this, haha. |
@thosakwe would you be able to post a link to your project somewhere? I'm wondering if it is related to feathersjs/feathers#259. Are you creating your own service? Are you missing |
@ekryski I believe it is related to #259. Here's the app.js: I'm at a loss, though. I tried using app.listen in my bin/www (this was originally an Express app) file, but now the error is "data and hash arguments required." So something I did breaks bcrypt somewhere. |
@thosakwe I need more than that to go on. The initial app setup looks just fine but I need to see how you set up your user service. If you don't have a user service set up, auth will not work. Additionally you need to make sure you are populating the user. Take a look at https://github.com/feathersjs/feathers-chat to see how those hooks are set up on the user service. |
@thosakwe Would you mind opening a new issue with the code for your app? That way it'll be much easier for us to keep track of instead of looking through the comments of a closed issue :) Thank you! |
Okay, cool. New issue: #108 |
Hello,
I have made it to create user, but when logging in, I got no luck. Code at gist.
My request was
It threw the exceptions:
But once I made some mistake, like
Content-Type: application/x-www-form-urle
, the rejecting json message was returnedCould anyone reproduce this?
The text was updated successfully, but these errors were encountered: