I recently run into a scenario highlighting that await
is not always a drop-in, better replacement for then
. Sometimes with then
it's easier to control the scope of the function that runs after the promise is settled. I have a Redux middleware-inspired example here:
https://codesandbox.io/s/eager-wildflower-1kodv?file=/src/index.js
In example 2, the next call will only happen after the promise resolves.
In example 3, the next will be called immediately.