Fetch list of lists from the API

This commit is contained in:
Sol Fisher Romanoff 2022-06-15 18:34:11 +03:00
parent d5d464a289
commit e18e179a59
No known key found for this signature in database
GPG key ID: 9D3F2B64F2341B62
4 changed files with 52 additions and 1 deletions

View 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