Skip to content

Instantly share code, notes, and snippets.

@daffl
Last active December 6, 2018 19:38
Show Gist options
  • Save daffl/df88e426f90057efc80bf0d4e3242714 to your computer and use it in GitHub Desktop.
Save daffl/df88e426f90057efc80bf0d4e3242714 to your computer and use it in GitHub Desktop.
Feathers React Native client
import io from 'socket.io-client';
import feathers from '@feathersjs/feathers'
import socketio from '@feathersjs/socketio-client'
const host = 'http://localhost:3030';
const socket = io(host, { transports: ['websocket'] });
// Set up Feathers client side
const app = feathers();
// Register socket.io
app.configure(socketio(socket));
// Get the messages service that talks to the server
const messages = app.service('messages');
// Log newly created messages
messages.on('created', message => {
console.log('Someone created a messages', message);
});
// Create a new message and then get a list of all messages
messages.create({ text: 'Hello from the browser' })
.then(() => messages.find())
.then(page => console.log('Messages', page));
@sonitx
Copy link

sonitx commented Nov 16, 2018

Can you help me to connect websocket from React Native to Feathers server version 2.0.0?

@bogdan2510
Copy link

this is not working.

@snooty7
Copy link

snooty7 commented Dec 6, 2018

It is not working for me too...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment