Start fetching.
This commit is contained in:
parent
7ce6bbcf30
commit
f8d6fe41f0
3 changed files with 118 additions and 53 deletions
|
@ -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')
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue