Skip to content

Commit

Permalink
fixed return promise inside contructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Iswan Jumat committed Oct 3, 2016
1 parent 6e76a4e commit aaf40cd
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions youpin-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@ class Api {
Api.refreshToken();
}, 23 * 60 * 60000); // Refresh token every 23 hours

app.authenticate({
type: 'local',
email: this.username,
password: this.password,
}).then(() => {
this.token = app.get('token');
}).catch((error) => {
console.log(error);
return new Promise((resolve, reject) => {
app.authenticate({
type: 'local',
email: username,
password: password, //eslint-disable-line object-shorthand
}).then(() => {
this.token = app.get('token');
resolve(this);
}).catch(error => {
console.log(error);
reject(error);
});
});
}

Expand Down

0 comments on commit aaf40cd

Please sign in to comment.