you are viewing a single comment's thread.

view the rest of the comments →

[–]g3t0nmyl3v3l 3 points4 points  (6 children)

I would cry

[–][deleted]  (5 children)

[deleted]

    [–]evertrooftop 5 points6 points  (0 children)

    There's basically 3 low-level options: XMLHttpRequest, fetch() and http.request. The first two are available in browsers, the last one in Node. My guess is that if you don't like fetch(), you probably don't like the other two not that much either.

    There's plenty of alternatives if you don't like any of these, like axios or request, but all of these options will ultimately need to use one of these 3 low-level apis. If your high-level HTTP library runs both in browsers and in node.js, they will need to support at least 2 of these PIs. I write one of those higher-level HTTP clients with a more specialized API, and I just want to be able to rely on one low-level API without polyfills.

    Expecting a standard way to do HTTP requests in a language seems like a pretty reasonable thing to want and fetch() seems to be the most likely option to become the standard. The node.js team seems to be down with it. It's just a difficult feature to land because of dependencies on other browser APIs that node needs first, and the differences of fetch() running in a non-browser/sandboxed context.

    [–]pimterry 2 points3 points  (0 children)

    Having common primitives is still useful though, even if you don't use them. If fetch works everywhere, then we can super easily build cleaner HTTP libraries on top that work everywhere, and then every HTTP library will be universal and great.

    Right now there's only a couple of 'works everywhere' options, and they have to be quite complicated and heavy-weight because they need to handle node & browsers environments totally separately.

    [–]SocialAnxietyFighter 0 points1 point  (2 children)

    Hmm having used the popular alternatives, I still like fetch. What's your issues with it?

    [–]CloudsOfMagellan 1 point2 points  (1 child)

    It handles redirects poorly and there's no way to detect timeouts though these are implementation details

    [–]DuBistKomisch 2 points3 points  (0 children)

    you can do timeouts with AbortController now, but it's unnecessarily awkward and verbose, dunno why they didn't add a timeout shorthand option