I have a promise P which checks a condition on the server (email verified).
P can either resolve -> email verified
or fail -> with code email unverified
or fail -> with code other error (email does not exist etc)
I want to create another promise WaitP that will wait for P to either resolve or fail with a code other than email unverified.
so WaitP does:
issue P
if P resolves, resolve WaitP
if P fails with code email unverified, go back to 1 (issue P again)
if P fail with a code other than email unverified, fail WaitP
How can I write such a promise ?
I am hoping for a solution without recursion.
thx!