Skip to content

Instantly share code, notes, and snippets.

@stephen

stephen/promiseSession.js

Last active Aug 29, 2015
Embed
What would you like to do?
var token = null;
Session.generate({ user: 'stephen' }).then(function(result) {
session.set('expirationTime', Date.now());
token = result.token;
return session.save();
}).then(function() {
// re-fetch
return Session.load(token);
}).then(function(fetchedSession) {
// do something with the newly fetched instance
assert.equals(fetchedSession.get('user'), 'stephen');
return fetchedSession.delete();
}).done();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment