Last active
April 11, 2017 06:41
-
-
Save ekryski/507a5d3648f7d18d14f5 to your computer and use it in GitHub Desktop.
Feathers Browser Configuration
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
<!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/[email protected]/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: '[email protected]', | |
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