22 lines
567 B
JavaScript
22 lines
567 B
JavaScript
|
import apiService from '../api/api.service.js'
|
||
|
|
||
|
const fetchAndUpdate = ({ store, credentials }) => {
|
||
|
return apiService.fetchFollowRequests({ credentials })
|
||
|
.then((requests) => {
|
||
|
store.commit('setFollowRequests', requests)
|
||
|
}, () => {})
|
||
|
.catch(() => {})
|
||
|
}
|
||
|
|
||
|
const startFetching = ({credentials, store}) => {
|
||
|
fetchAndUpdate({ credentials, store })
|
||
|
const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store })
|
||
|
return setInterval(boundFetchAndUpdate, 10000)
|
||
|
}
|
||
|
|
||
|
const requestFetcher = {
|
||
|
startFetching
|
||
|
}
|
||
|
|
||
|
export default requestFetcher
|