This question already has an answer here:
- How do I access previous promise results in a .then() chain? 15 answers
I'm using the return pattern
to prevent me from making promise ugly cascade.
Here is an exemple, I'm calling two function one after the other myfunction1
and myfunction2
myfunction1().then((value1) => {
return myfunction2()
}).then((value2) => {
console.log(value1)
}).catch((err) => {
console.error(err)
})
How can I access value1
inside the then
of the seconde function ?