Skip to content

Instantly share code, notes, and snippets.

@ekryski
Last active April 11, 2017 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekryski/507a5d3648f7d18d14f5 to your computer and use it in GitHub Desktop.
Save ekryski/507a5d3648f7d18d14f5 to your computer and use it in GitHub Desktop.
Feathers Browser Configuration
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Feathers Example</title>
</head>
<body>
<h1>Welcome to Feathers</h1>
<p>Open up the console in your browser.</p>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/core-js/2.1.4/core.min.js"></script>
<script type="text/javascript" src="//npmcdn.com/feathers-client@2.0.0/dist/feathers.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script type="text/javascript">
// Set up socket.io
var socket = io('http://localhost:3030');
// Set up Feathers client side
var app = feathers();
// Register hooks module
app.configure(feathers.hooks());
// Register socket.io
app.configure(feathers.socketio(socket));
// Set up authentication with a store to cache your auth token
app.configure(feathers.authentication({ storage: window.localStorage }));
// Authenticating using a email and password
app.authenticate({
strategy: 'local',
email: 'admin@feathersjs.com',
password: 'admin'
}).then(function(result){
console.log('Authenticated!', result);
// Find our users on the server via sockets
app.service('users').find({}).then(function(users){
console.log('Users!', users);
});
}).catch(function(error){
console.error('Error authenticating!', error);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment