frequi_origin/src/store/index.js
2020-05-06 21:23:45 +02:00

38 lines
727 B
JavaScript

import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios';
import ftbotModule from './modules/ftbot';
import { apiBase } from './modules/config';
Vue.use(Vuex)
export default new Vuex.Store({
state: {
ping: 'ddd',
},
modules: {
ftbot: ftbotModule
},
mutations: {
setPing(state, ping) {
console.log(ping);
const now = Date(Date.now());
state.ping = `${ping.status} ${now.toString()}` ;
}
},
actions: {
ping({ commit }) {
axios.get(`${apiBase}/ping`)
.then((result) => commit('setPing', result.data))
.catch(console.error);
},
refresh_all({dispatch}) {
// Refresh all data
dispatch('ftbot/getTrades');
}
}
})