반응형
Vue/Bluebird: 콜백이 실행되지 않음
의 then()this.getStationsAsync()
실행하지 않습니다.그catch()
그렇지 않기 때문에 거부되는 것은 없을 것입니다.혹시 제가 잘못하고 있는 건 아닐까요?Promise.promisify(this.getStations)
?
나도 해봤어this.getStationsAsync = Promise.promisify(this.getStations)
내부created()
훅. 에러는 안 나오지만, 아무것도 안 나오네요.console.logs()
그 결과,then()
실행했다.
import Vue from 'vue'
import axios from 'axios'
import Promise from 'bluebird'
methods:{
createStationMarkers (selectedNetworkMarker) {
this.selectedNetwork = selectedNetworkMarker
this.hideNetworkMarkers()
debugger
this.getStationsAsync()
.then(() => {
debugger
console.log('inside then')
this.addStationMarkers()
this.test = true
})
.catch(error => {
console.log(error)
})
}
},
getStations () {
axios
.get('/api/network/' + this.selectedNetwork.id)
.then(res => {
for (let station of res.data.stations) {
this.stations.push(station)
}
return res.data.stations
})
.catch(error => {
console.log(error)
})
}
}
computed: {
getStationsAsync () {
return Promise.promisify(this.getStations)
}
}
공리 호출 결과를 반환해야 합니다.이것은 약속입니다.
getStations () {
return axios
.get('/api/network/' + this.selectedNetwork.id)
.then(res => {
for (let station of res.data.stations) {
this.stations.push(station)
}
return res.data.stations
})
.catch(error => {
console.log(error)
})
}
}
Bluebird는 필요 없습니다.전화만 하면 됩니다.getStations
부터createStationMarkers
.
언급URL : https://stackoverflow.com/questions/46426514/vue-bluebird-then-callback-doesnt-run
반응형
'itsource' 카테고리의 다른 글
Vuetify 데이터 테이블 작업 행 (0) | 2022.08.28 |
---|---|
vue-apollo 클라이언트에서 GraphQL 입력 유형을 정의하는 방법 (0) | 2022.08.28 |
ByteBuffer.allocate()와ByteBuffer.allocateDirect() (0) | 2022.08.28 |
Vuex Store의 작업 내에서 푸시 경로 푸시 (0) | 2022.08.28 |
여러 요청 수행 Axios(Vue.js) (0) | 2022.08.28 |