Refactor /api/web APIs to use the centralized axios instance (#6223)

Also adds the ability to decouple the centralized axios logic from the
state dispatcher
This commit is contained in:
nightpool
2018-01-08 14:01:33 -05:00
committed by Eugen Rochko
parent ff6ca8bdc6
commit c235711ffe
5 changed files with 21 additions and 13 deletions

View File

@ -1,4 +1,4 @@
import axios from 'axios';
import api from '../api';
import { debounce } from 'lodash';
export const SETTING_CHANGE = 'SETTING_CHANGE';
@ -23,7 +23,7 @@ const debouncedSave = debounce((dispatch, getState) => {
const data = getState().get('settings').filter((_, path) => path !== 'saved').toJS();
axios.put('/api/web/settings', { data }).then(() => dispatch({ type: SETTING_SAVE }));
api(getState).put('/api/web/settings', { data }).then(() => dispatch({ type: SETTING_SAVE }));
}, 5000, { trailing: true });
export function saveSettings() {