UNPKG

vuex-xhr-state

Version:

Use Vuex to manage the state of you're ajax calls.

21 lines (20 loc) 565 B
export default (function (options) { var state = { PENDING: {}, }; if (options.cache) { state.ERROR = {}; state.FETCHED = {}; state.DEFAULT = options.default; state.RESPONSE = {}; } if (options.store && options.store.state) { for (var key in options.store.state) { if (options.store.state instanceof Object && !options.store.state.hasOwnProperty(key)) { continue; } state[key] = (options.store.state)[key]; } } return state; });