Replacing callback examples with promise based examples #742
Replies: 1 comment 4 replies
-
Just to be clear, the examples using But, I think it's a good idea to use async/await instead of I think there's a suggestion that you might want to keep the code in an async function, so people don't try running the example outside one and be surprised when it doesn't work. In https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch I did this for more complete examples but not for little snippets. |
Beta Was this translation helpful? Give feedback.
-
I was just reading through the fetch api docs and was kind of surprised to see all the examples using callbacks. I checked other pages and there are many like it. Is there a reason for this? Would anyone object if I rewrote these using promises?
Change to
I’ll be making these changes here for my own reference https://developer.typescripts.org/en-US/docs/Web/API/Window/fetch
Beta Was this translation helpful? Give feedback.
All reactions