Skip to content

Instantly share code, notes, and snippets.

@stephen
Last active August 29, 2015 14:11
Show Gist options
  • Save stephen/a7a89b5e4c6b8dd1116f to your computer and use it in GitHub Desktop.
Save stephen/a7a89b5e4c6b8dd1116f to your computer and use it in GitHub Desktop.
static load(token) {
return new Promise((resolve, reject) => {
this._createQuery().get(token).then((data) => {
resolve(new this(data));
}, (err) => {
if (err.code === 101) {
resolve(null); // model with token does not exist.
} else {
reject(new Error(err));
}
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment