3

What’s 2020s way of consuming a REST API in React? Too many options!

Comments
  • 1
    It's 'just' an API call right?

    Or are you looking for something that examines the data ... manages the state in a more complex manner or something?
  • 6
    Don't worry we only got 2 days left
  • 3
    Axios is decent one but plain fetch is actually all you need. We are using custom util function built on top fetch. Its about 100 lines and contains things like url normalization, different domains for different environments, error handling, json parsing etc. We never had any problem with it
  • 2
    @hack 🙇 I'm glad I'm not the only one considering the fetch route. Thanks!
  • 0
    @devphobe if it works, remember to publish the package if for no other reason than to further muddy the waters for 2022.
  • 0
    @HiFiWiFiSciFi I hate the proliferation of packages. For this project I’ve already copied the twenty lines of code out of thousands that would have been brought in with npm. I could publish my own minimal package, but this is crucial to our app security , and the risk of upstream poisoning here seems too great.
  • 0
    @devphobe

    You certainly don't need a package to fetch something or build your own a wrapper around it do some minimal checks and so forth.

    And yet some rando package almost sounds like what you were asking for ;)
  • 1
    Just use fetch

    /non-react developer
  • 0
    /api?query=select * from user
Add Comment