Start fetching.

This commit is contained in:
Roger Braun 2016-10-28 14:26:51 +02:00
parent 7ce6bbcf30
commit f8d6fe41f0
3 changed files with 118 additions and 53 deletions

View file

@ -1,4 +1,5 @@
import apiService from '../services/api/api.service.js'
import timelineFetcher from '../services/timeline_fetcher/timeline_fetcher.service.js'
const users = {
state: {
@ -17,13 +18,15 @@ const users = {
}
},
actions: {
loginUser ({commit, state}, userCredentials) {
loginUser (store, userCredentials) {
const commit = store.commit
commit('beginLogin')
apiService.verifyCredentials(userCredentials)
.then((response) => {
if (response.ok) {
response.json()
.then((user) => commit('setCurrentUser', user))
.then(() => timelineFetcher.startFetching({store, credentials: userCredentials}))
}
commit('endLogin')
})