import Vue from 'vue' import Vuex from 'vuex' import axios from 'axios'; Vue.use(Vuex) export default new Vuex.Store({ state: { answers: [], questions: [] }, mutations: { startWithFirstQuestion() { this.state.currentQuestion = 0 }, answerQuestion(state, pl) { this.state.answers[pl.id] = pl.answer }, init() { axios.get('https://avian-safeguard-214619.firebaseio.com/questions.json') .then(res => { console.log(res) this.state.questions = res.data this.state.answers = Array.apply(0, Array(res.data.length)).map(function () {}) }) } }, getters: { numberQuestions: (state) => { return state.questions.length } }, actions: { }, modules: {} })