I just radically simplified a fetch call


I just radically simplified a fetch call.

Before: 26 lines.
After: 6 lines.

Here are 8 ways to simplify a fetch function.

Why I prefer function declarations for top-level functions:

1. They're more scannable - It's easier to see at a glance that they're functions, not mere variables.

2. Order doesn't matter. Function declarations are hoisted.

3. Can export default on the same line if desired.

Oops, accidentally left an arrow in the after example. Here's a fixed comparison:

View original on X