Last active
December 6, 2018 19:38
-
-
Save daffl/df88e426f90057efc80bf0d4e3242714 to your computer and use it in GitHub Desktop.
Feathers React Native client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
this is not working.
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
Can you help me to connect websocket from React Native to Feathers server version 2.0.0?