In JS, let's say I call a promise in a 'fire and forget' way. I don't care if it was successful or not, and I don't care what it returns as I want to return the same value anyways.
I can call
return myPromise().then(() => foo).catch(() => foo);
Is there a way to not repeat then then
and catch
parts?
What I've tried
I thought about using finally
, thinking that it will take what finally returns (similar to what Java does by taking the return value of the finally block) :
return myPromise().finally(() => foo);
But it turns out it didn't do what I expected. According to mdn, this return value will be used to reject in case the original promise rejected.