Last active
November 30, 2018 16:38
-
-
Save diegomengarda/ba337e56a6b508b4ac54778f65141be0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Api from '../common/api/Api' | |
export default class Auth extends Api { | |
constructor () { | |
super() | |
this.setDomain('auth') | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Api from '../common/api/Api' | |
import store from '../../../vuex' | |
export default class Auth extends Api { | |
constructor () { | |
super() | |
this.setDomain('auth') | |
} | |
async login (data) { | |
return new Promise((resolve, reject) => { | |
this.post({route: 'login', data}) | |
.then(loginResponse => { | |
store.dispatch('login', loginResponse).then((response) => { | |
resolve(response) | |
}) | |
}) | |
.catch(e => { | |
console.log(e) | |
reject() | |
}) | |
}) | |
} | |
async logout () { | |
return new Promise((resolve, reject) => { | |
let data = {} | |
this.post({route: 'logout', data}) | |
.then(() => { | |
store.dispatch('logout').then(() => { | |
resolve() | |
}) | |
}) | |
.catch(e => { | |
console.log(e) | |
reject() | |
}) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment