Can’t seem to figure out what I’m missing here, so reaching out for help.
Simply put, I want to achieve this in Vue (https://codesandbox.io/s/6zlmkm61m3)
function p1() {
return new Promise((resolve, reject) => {
console.log('p1')
resolve()
})
}
function p2() {
return new Promise((resolve, reject) => {
console.log('p2')
reject('p2')
})
}
p1()
.then(p2)
.catch((error) => {
console.log(error)
})
When I try to do this in Vue, I encounter an Uncaught (in promise)
error.
https://codesandbox.io/s/mq2343y6p8
I’m not certain if this issue is related to Vue or how I am invoking the methods. Any assistance would be greatly appreciated.
Vue code:
export default {
name: "App",
components: {
Hello,
World
},
data() {
return {};
},
methods: {
checkPromise() {
this.$refs.promiseOne
.p1()
.then(this.$refs.promiseTwo.p2())
.catch(error => {
console.log(error);
});
}
}
};