Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import axios from 'axios'
import uuid from 'uuid'
import {datastoreConstants} from 'constants'
import * as backgroundTaskActions from './backgroundTaskActions'
export function fetchAllDatastores () {
return (dispatch, getState) => {
const taskId = uuid.v4()
dispatch(backgroundTaskActions.addTask(taskId, 'Fetching datastores…'))
axios.get('/graphql', {
params: {
query: '{user{addons{id,plan,service}}}'
}
}).then((response) => {
dispatch({
type: datastoreConstants.BULK_ADD_DATASTORES,
payload: response.data.data.user.addons
})
}).catch((error) => {
console.error(`Unable to fetch datastores: ${error}`)
}).then(() => {
dispatch(backgroundTaskActions.removeTask(taskId))
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.