Here's the method I'm using, it's pretty straightforward.
DailyCountTest: function (){
this.$store.dispatch("DailyCountAction")
let NewPatientTest = this.$store.getters.NewPatientCountGET
console.log(NewPatientTest)
}
The getter retrieves data from a simple action that accesses a django backend API.
I'm trying to create some charts with the data, so I need to store them in variables. The issue is that I can't seem to access these variables.
Here's what the console displays
You can see the contents, but there are also empty brackets. Does anyone know how I can access those values? I've tried various map.(Object) methods but haven't had any success.
Any tips on how to manipulate this array and extract the contents?
Thank you!
Below is the Vuex path for the API data
Action:
DailyCountAction ({ commit }) {
axios({
method: "get",
url: "http://127.0.0.1:8000/MonthlyCountByDay/",
auth: {
username: "test",
password: "test"
}
}).then(response => {
commit('DailyCountMutation', response.data)
})
},
Mutation:
DailyCountMutation(state, DailyCount) {
const NewPatientMap = new Map(Object.entries(DailyCount));
NewPatientMap.forEach((value, key) => {
var NewPatientCycle = value['Current_Cycle_Date']
state.DailyCount.push(NewPatientCycle)
});
}
Getter:
NewPatientCountGET : state => {
return state.DailyCount
}
State:
DailyCount: []