Re:I loved jQuery, and still do (2019)
by chrismorgan on Tuesday June 29, 2021 @02:37PM
(#27679942)
Hmm, forgot about that style. Where you only have prefix await, .then() can end up nicer (though I might split it into `const response = await fetch('/my/url'); const data = await response.json();` as yet another style), but if you can have suffix await, I reckon it’s much nicer. Goes well with fluent API styles.
Re:I loved jQuery, and still do (2019)
by johannes1234321 on Wednesday June 30, 2021 @05:15AM
(#27686519)
> Hmm, forgot about that style. Where you only have prefix await, .then() can end up nicer
Mind that in this example the then is a little nicer only by chance that the continuation is quite trivial. If you'd need something more complex than the single function call it is annoying and if you do any later change to this code, you likely have to change this as well.
I typically go to the multiple lines, but wanted to show that there is a kind-off suffix await.
I am not used to suffix await, as i like to spot the places where i jump out of the coroutine easily. But maybe that would change if I'd use languages with suffix await more :)
const data = await fetch('/my/url').then(r => r.json());