-
Notifications
You must be signed in to change notification settings - Fork 27
How to access feathers-client #102
Comments
Feathers client is intended to help you get connected to your Feathers server's services. You don't need routes, you just create services with URLs that match the ones you created on the server. var feathers = require('feathers/client');
var io = require('socket.io-client/socket.io');
var socketio = require('feathers-socket.io/client');
var hooks = require('feathers-hooks');
var auth = require('feathers-authentication/client');
var socket = io('http://localhost:3030', {
transports: ['websocket']
});
var app = feathers()
.configure(socketio(socket))
.configure(hooks())
.configure(auth());
var messageService = app.service('/match/the/server/url/for/messages');
messageService.find({query:{put query here}}).then(function(response){
// Messages will be at response.data if you have pagination turned on.
// Otherwise response will be an array of messages.
}); |
One additional note is that the client only lets you connect to Feathers services not any other custom routes you have registered. Basic Express routes are only available via HTTP and a client like request. |
Okay, thanks so far! So if I want to build a normal webapp with views and custom urls I have to use something like express for routes and views and feathers client for sending events to my feathers server and receiving events from it? |
@nicoknoll Depends what you mean by "normal webapp", you can use feathers-client from React to communicate with your Feathers API as well. Or as you had mentioned you can render views from the server using express then once loaded fetch data using feathers-client. If you're rendering from the server you can also fetch data from your feathers services on the server and use that data when rendering your templates. |
Okay, I think I got it. Big thanks to anyone. I think I was just confused by the var naming of |
Agreed about the naming potentially being confusing, something like: may make more sense since |
This should help people like me who could get confused by having "feathersClient" called "app" but not being able to use it as "app" in feathers (not client) or express. Regarding: feathersjs-ecosystem#102
* Change variable naming from "app" to "feathersClient" This should help people like me who could get confused by having "feathersClient" called "app" but not being able to use it as "app" in feathers (not client) or express. Regarding: #102 * client instead of feathersClient
Closed via #103, thank you! |
Hey,
this is not really an issue but probably me misunderstanding some part of the concept of feathers-client.
So what I want to have is a feathers server and a separate client with react. The server ist working fine and I can connect to the feathers services running on the server from client with
socket = io('http://localhost:3030/')
.But what I don't get is how I can access the client in the browser now. I tried to setup routes with
app.use
but then I get the errorMiddleware functions can not be used in the Feathers client
.So how can I setup routes and define the port on which I can access the client (
app.listen(port)
isn't doing anything as well)?The text was updated successfully, but these errors were encountered: