0
Axios에서 문제가 발생합니다. Vuex에서 머리글 가져 오기 - VueJS, 여러분이 도와 주길 바랍니다.Axios Vuex에서 머리글 가져 오기 - NUXTJS
페이지 :
<template>
<div class="temp">{{users.info}}</div>
</template>
<script>
data: function() {
return {
config: {
'headers': {'Authorization': 'JWT ' + this.$store.state.token}
}
}
},
fetch ({ store, params }) {
return store.dispatch('getProfile', params, this.config)
},
</script>
Vuex 모듈 :
import api from '~/plugins/axios'
const state =() => {
return {
info: null
}
}
const actions = {
getProfile ({commit}, params, config) {
return new Promise((resolve, reject) => {
api.get(`/users/${params.username}/`, config)
.then(response => {
commit('GET_USER_DETAIL', response.data)
resolve(response.data)
},
response => {
reject(response.data)
})
})
}
}
const getters = {}
const mutations = {
GET_USER_DETAIL (state, info) {
state.info = info
}
}
export default {
state,
actions,
getters,
mutations
}
문제 : Vuex 모듈 설정이 정의되어 있지 않습니다.
나는 당신의 도움을 바라는 뭔가 잘못 생각합니다. 미리 감사드립니다.
많은 분들께 감사드립니다. :) –