New to vuex and nuxt so there may be a very simple fix to this. I have two middlewares, one makes an api call with AXIOS to github and the other pulls from a RSS feed of a medium.com user that convert to JSON.
The github mutation works fine when committing to store, the medium mutation does not commit to the store.
// store/index.js
export const state = () => ({
github: [],
medium: [],
blog: []
})
export const mutations = {
ADD_MEDIUM(state, data) {
data.items.forEach((el) => {
state.medium.push({
'createdOn': el.pubDate,
'title': el.title,
'url': el.link
})
})
},
ADD_GITHUB(state, data) {
if(state.github.length === 0){
data.data.forEach((el) => {
state.github.push({
'createdOn': el.created_at,
'title': el.full_name,
'url': el.html_url
})
})
}
},
}
// middleware/medium.js
import rssParser from 'rss-parser'
let parser = new rssParser()
export default function ({ store, route }) {
parser.parseURL('https://medium.com/feed/@user_name')
.then((resp) => {
store.commit('ADD_MEDIUM', resp)
})
}
// middleware/github.js
import axios from 'axios'
export default function ({ store, route }) {
axios.get('https://api.github.com/users/user_name/repos')
.then((resp) => {
store.commit('ADD_GITHUB', resp)
})
}
console.logged the value ofrespto make sure it's what you expect? - ceejayozconsole.logstate and data within the mutation. Try pushing something static, likestate.medium.push({ foo: 'bar' })for the mutation. etc. - ceejayoz