2 ms·
That wasn't the reason promises were introduced. An XMLHttpRequest can be synchronous which is Bad™ and that is something explicitly not allowed by the Promise/
by idbehold 10y ago
That wasn't the reason promises were introduced. An XMLHttpRequest can be synchronous which is Bad™ and that is something explicitly not allowed by the Promise/A+ spec which means it will never be something that fetch() could do. The advantage of promises is that they can be `await`ed in the context of an `async` function which takes a lot of the cognitive load off of the developer.
- Klathmon 10y agoFurthermore the `await` syntax is one of the reasons why cancelable promises is contentious. There's no easy way to "cancel" an awaited promise without basically resorting to the .then() syntax.