Fetch list of lists from the API
This commit is contained in:
parent
d5d464a289
commit
e18e179a59
4 changed files with 52 additions and 1 deletions
22
src/services/lists_fetcher/lists_fetcher.service.js
Normal file
22
src/services/lists_fetcher/lists_fetcher.service.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
import apiService from '../api/api.service.js'
|
||||
import { promiseInterval } from '../promise_interval/promise_interval.js'
|
||||
|
||||
const fetchAndUpdate = ({ store, credentials }) => {
|
||||
return apiService.fetchLists({ credentials })
|
||||
.then(lists => {
|
||||
store.commit('setLists', lists)
|
||||
}, () => {})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
const startFetching = ({ credentials, store }) => {
|
||||
const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store })
|
||||
boundFetchAndUpdate()
|
||||
return promiseInterval(boundFetchAndUpdate, 240000)
|
||||
}
|
||||
|
||||
const listsFetcher = {
|
||||
startFetching
|
||||
}
|
||||
|
||||
export default listsFetcher
|
Loading…
Add table
Add a link
Reference in a new issue