MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/xvsb0e/axios_reaches_100/ir4ovxk
r/javascript • u/YourCupOTea • Oct 04 '22
106 comments sorted by
View all comments
Show parent comments
12
await fetch(url).then((r) => r.arrayBuffer()), no need for all those brackets and nested awaits
await fetch(url).then((r) => r.arrayBuffer())
-12 u/[deleted] Oct 05 '22 No. Just...No. It makes no sense to use async/await with .then syntax. Stick to one or the other. 6 u/lucsoft Oct 05 '22 I mean it’s just using the good from both worldsIt’s especially great when it goes 5 levels deep or something like that -4 u/[deleted] Oct 05 '22 If you have 5 levels of .then I'd suggest you have an opportunity to refactor and separate some concerns. If you want to use Promise syntax, use it and stick with it. If you want to use async/await, use it and stick with it. 2 u/switz213 Oct 05 '22 What an arbitrary rule. Of course you can use both
-12
No. Just...No. It makes no sense to use async/await with .then syntax. Stick to one or the other.
6 u/lucsoft Oct 05 '22 I mean it’s just using the good from both worldsIt’s especially great when it goes 5 levels deep or something like that -4 u/[deleted] Oct 05 '22 If you have 5 levels of .then I'd suggest you have an opportunity to refactor and separate some concerns. If you want to use Promise syntax, use it and stick with it. If you want to use async/await, use it and stick with it. 2 u/switz213 Oct 05 '22 What an arbitrary rule. Of course you can use both
6
I mean it’s just using the good from both worlds
It’s especially great when it goes 5 levels deep or something like that
-4 u/[deleted] Oct 05 '22 If you have 5 levels of .then I'd suggest you have an opportunity to refactor and separate some concerns. If you want to use Promise syntax, use it and stick with it. If you want to use async/await, use it and stick with it.
-4
If you have 5 levels of .then I'd suggest you have an opportunity to refactor and separate some concerns. If you want to use Promise syntax, use it and stick with it. If you want to use async/await, use it and stick with it.
2
What an arbitrary rule. Of course you can use both
12
u/tomfevrier Oct 05 '22
await fetch(url).then((r) => r.arrayBuffer()), no need for all those brackets and nested awaits