Answer the question
In order to leave comments, you need to log in
How to work with asynchronous data?
Hello. I ran into a problem with processing the data that I receive through an ajax request. The essence of the problem is that I do not understand how json should be processed. Because js always throws 'undefined properties'.
1) In Vuex, I created an action that receives json:
SET_RATING: async (context, payload) => {
let data = await Axios.get('https://r-volsu.ru/api/rating/ИВТм-181');
context.commit('SET_RATING', data.data);
}
computed:{
semester(){
let result = this.$store.getters.RATING.rating; // тут json все нормально
let current = this.$store.getters.RATING.currentSemester; // "Первый семестр"
result[current] // вот тут и получаю undefined properties
}
}
Answer the question
In order to leave comments, you need to log in
What is your JSON format? Is it just a string or already parsed JSON as an object?
If this is a string, then you need to parse -const data = JSON.parse(jsonData)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question