Written on
·
297
1
저는 강사님과는 다르게 return문을 fetchList 앞에 안 붙였는데도 스피너가 동작하길래 한번 콘솔을 찍어봤는데
actions의
FETCH_LIST({commit}, pageName){
// api - index.js
fetchList(pageName)
// mutation "SET_LIST"
.then(({ data }) => {
console.log(4)
commit("SET_LIST", data)
})
.catch(console.log)
},
이 함수는 return문이 생략되어 있으니 undefined를 반환할 거라 예상했습니다
ListMixin.js
created(){
bus.$emit('start:spinner') // 'start:spinner' 이벤트 보낸다 App.vue로
setTimeout(()=>{
console.log(this.$store.dispatch('FETCH_LIST', this.$route.name))
this.$store.dispatch('FETCH_LIST', this.$route.name)
.then((res)=>{
console.log(5)
console.log(res)
console.log('fetched')
bus.$emit('end:spinner') // 데이터 불러오고 나면 end:spinner
}) // actions의 FETCH_NEWS의 return response를 받음
.catch(console.log)
},3000)
},
근데 여기서 확인해보니 this.$store.dispatch('FETCH_LIST', this.$route.name)이 promise 객체던데 왜 그런건가요?
Answer 1
0