After explaining the bug, I discovered something interesting;
Component codes
async fetch(){ await this.$store.dispatch('bots/getBots') },
computed: { ...mapState('bots', ['bots']) },
Store codes
export const state = () => {
return {
bots: []
}
}
export const mutations = {
UPDATE_BOTS(state, bots) {
state.bots = bots
}
}
export const actions = {
getBots({commit}) {
this.$axios.$get('url', {headers: {uid: '12345'}})
.then(res => {
commit('UPDATE_BOTS',res.robots)
})
.catch(e => {
console.log(e)
})
}
}
Issue: The data loads perfectly when moving between pages via nuxt-link, but upon reloading the page the bots state becomes empty...
Discovery: While using nuxt-auth, a plugin was added to check the status of axios requests. If a request returned as unauthorized (401), it would automatically log out the user if they were logged in. However, after commenting out the plugin code, a different error related to nuxt-auth surfaced causing the initial problem. This issue has been linked to another question that can be viewed here: Nuxt-Auth Bug: Looks for autherization in any get request that has headers config