covidassist/src/store/index.js

41 lines
1.0 KiB
JavaScript

import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios';
Vue.use(Vuex)
export default new Vuex.Store({
state: {
surveyCompletedOnce: false,
answers: [],
questions: []
},
mutations: {
startWithFirstQuestion() {
this.state.currentQuestion = 0
},
answerQuestion(state, pl) {
this.state.answers[pl.id] = pl.answer
},
setSurveyCompleted() {
this.state.surveyCompletedOnce = true
},
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: {}
})