Skip to content

Commit

Permalink
Sugar client: fix Promise.all
Browse files Browse the repository at this point in the history
Missed in #135: Promise.all should take an array as an argument. I've also added better error-logging to debug Sugar client errors.
  • Loading branch information
eatyourgreens committed May 6, 2021
1 parent fc7f305 commit bfce5ae
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/sugar.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if (typeof navigator !== 'undefined') {
var sugarClient = new SugarClient();

auth.listen('change', function() {
Promise.all(auth.checkCurrent(), auth.checkBearerToken())
Promise.all([auth.checkCurrent(), auth.checkBearerToken()])
.then(function([ user, token ]) {
if (user && token) {
sugarClient.userId = user.id;
Expand All @@ -41,6 +41,7 @@ if (typeof navigator !== 'undefined') {
}
})
.catch(function(e) {
console.error(e)
throw new Error('Failed to checkCurrent auth from sugar client');
});
});
Expand Down

0 comments on commit bfce5ae

Please sign in to comment.