of undefined. Почему так?
export const getters = {
validPosts(state) {
return state.posts.filter(p => {
return p.title && p.body
})
},
export const actions = {
async fetchPosts({ commit, getters, dispatch }, limit = 3) {
const res = await axios.get(
'https://jsonplaceholder.typicode.com/posts?_limit=' + limit
)
const posts = this.res
убрал из "const posts = this. res" ключевое this => TypeError: state.posts.filter is not a function
Обсуждают сегодня