Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

How to get hooks socketio etc from feathers object #118

Closed
osenvosem opened this issue Nov 24, 2016 · 6 comments
Closed

How to get hooks socketio etc from feathers object #118

osenvosem opened this issue Nov 24, 2016 · 6 comments

Comments

@osenvosem
Copy link

osenvosem commented Nov 24, 2016

According the documentation hooks or restshould be available on feathers object, but there is no any. I'm using it with webpack:

const feathers = require('feathers/client'); or just ('feathers');

feathers.rest === undefined
feathers.hooks === undefined

What am I doing wrong?

@daffl
Copy link
Member

daffl commented Nov 24, 2016

You are using feathers/client this is the feathers-client module (const feathers = require('feathers-client')). As the Readme says:

While Feathers and its modules can be used on the client with an NPM compatible module loader like Browserify, Webpack or StealJS, feathers-client consolidates a standard set of client plugins into a single distributable that can be used standalone in the browser or with other module loaders (like RequireJS) that don't support NPM.

This means you should only use it if you don't use a module loader that supports NPM.

@osenvosem
Copy link
Author

@daffl so with webpack I suppose to import client modules separately and can't use feathers-client module? like so:

const feathers = require('feathers/client');
const rest = require('feathers-rest/client');
const auth = require('feathers-authentication/client');
etc...

It seems a little confusing.

@daffl
Copy link
Member

daffl commented Nov 24, 2016

@daffl
Copy link
Member

daffl commented Nov 24, 2016

You can still use the feathers-client module if you want. Just use const feathers = require('feathers-client'). You might just end up including things you don't use that way.

@osenvosem
Copy link
Author

@daffl thank you for the answers.
One more thing: I got an error in browser every time I am trying to configure rest:

Uncaught TypeError: fn.call is not a function(…)

It leads here:
screen shot 2016-11-24 at 20 08 57

The code:

const feathers = require('feathers/client');
const rest = require('feathers-rest/client');
const hooks = require('feathers-hooks');


const client = feathers()
  .configure(hooks())
  .configure(rest());

@daffl
Copy link
Member

daffl commented Nov 24, 2016

Probably a Webpack configuration issue somewhere. It worked when I tried it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants