Как положить переменную в мутацию?
Подскажите пожалуйста как мне положить переменную result в мутацию setStatiscticsForChart_mutations? Я совсем новичок. Не могу понять ошибка из за чего.
Module Error (from ./node_modules/eslint-loader/index.js):
C:\Users\Vladik\Desktop\cryptocurrency-calculator\src\vuex\store.js
17:13 error Duplicate key 'result' no-dupe-keys
✖ 1 problem (1 error, 0 warnings)
@ ./src/main.js 7:0-33 10:8-13
@ multi (webpack)-dev-server/client?http://192.168.0.101:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
let store = createStore({
state() {
return {
maturityList: [],
maturity: null,
underlying: null,
amount: null,
futHedgeFlag: false,
fullDataList: null,
chartData: null,
result: null,
value: null,
result: [],
}
},
mutations: {
setMaturityList_mutations(state, maturityList) {
state.maturityList = maturityList
},
setMaturity_mutations(state, maturity) {
state.maturity = maturity
},
setUnderlying_mutations(state, underlying) {
state.underlying = underlying
},
setAmount_mutations(state, count) {
state.amount = count
},
setFlagFutures_mutations(state, flag) {
state.futHedgeFlag = flag
},
setFullData_mutations(state, data) {
state.fullDataList = data
},
setStatiscticsForChart_mutations(state, statistic) {
state.chartData = statistic
}
},
actions: {
getMaturity_actions({ commit }, underlying) {
return new Promise(( resolve, reject) => {
axios({ url: 'http://localhost:5000/maturities', params: {currency: underlying}, method: 'GET'})
.then(resp => {
const data = resp.data.data[underlying]
commit('setMaturityList_mutations', data)
resolve(resp)
})
.catch(resp => {
reject(resp)
})
})
},
getStatisctics_actions({ commit }) {
return new Promise(( resolve, reject) => {
axios({ url: 'http://localhost:5000/recStructs', params: {currency: this.state.underlying, maturity: this.state.maturity, amount: this.state.amount, fut_hedge_flag: this.state.futHedgeFlag}, method: 'GET'})
.then(resp => {
commit('setFullData_mutations', resp.data.data)
const key = this.fullDataList[5]["chart"]["y_struct"]
const value = this.fullDataList[5]["chart"]["x"]
const result = {}
key.forEach((key,i) => result[key] = value[i])
commit('setStatiscticsForChart_mutations', result)
.catch((error) =>{
console.log(error)
})
resolve(resp)
})
.catch(resp => {
reject(resp)
})
})
}
},
getters: {
maturityList: state => state.maturityList,
fullDataList: state => state.fullDataList
}
})
export default store;