Before
export default Torii.extend({
torii: service('torii'),
authenticate() {
return new RSVP.Promise((resolve, reject) => {
this._super(...arguments).then((data) => {
raw({
url: `${config.apiHost}/api/tokens/oauth/grant`,
type: 'POST',
dataType: 'json',
data: { 'grant_type': 'facebook_auth_code', 'auth_code': data.authorizationCode }
}).then((response) => {
resolve({
access_token: response.accessToken,
provider: data.provider,
user_id: response.userId
})
}, reject)
}, reject)
})
}
})
After
export default Torii.extend({
torii: service('torii'),
async authenticate() {
const data = await this._super(...arguments)
const response = await raw({
url: `${config.apiHost}/api/tokens/oauth/grant`,
type: 'POST',
dataType: 'json',
data: { 'grant_type': 'facebook_auth_code', 'auth_code': data.authorizationCode }
})
return {
access_token: response.accessToken,
provider: data.provider,
user_id: response.userId
}
}
})
Just thought it could simplify life (if you have the regenerator runtime installed).
Before
After
Just thought it could simplify life (if you have the regenerator runtime installed).