GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — global default options and handlers · Issue #22 · developit/unfetch

global default options and handlers #22

New issue
Copy link
New issue
Copy link
Open
Open
global default options and handlers#22
Copy link
Labels
possible-addon

Description

@farskid
farskid
opened on Feb 23, 2017
Issue body actions

Since fetch apis are used a lot in a typical web application, it would be nice to have a unfetch.defaults object that sets default parameters of all requests.
A use case would be to set base URL of all requests.

unfetch.defaults.baseURL = 'my-api-endpoint'
Reacted by Charlike Mike Reagent and Andra Malmén

Activity

  1. tunnckoCore commented on Feb 23, 2017

    @tunnckoCore
    tunnckoCore
    on Feb 23, 2017
    Collaborator
    More actions

    Sounds good, but don't believe we can get 500b, haha

    Reacted by Farzad Yousefzadeh
  2. farskid commented on Feb 23, 2017

    @farskid
    farskid
    on Feb 23, 2017
    Author
    More actions

    Well, having a useful feature to cost some bytes wouldn't harm I guess.
    Let's watch the package size to see if there is a chance for adding this feature.

    Reacted by Charlike Mike Reagent and Balázs Édes
  3. tunnckoCore commented on Feb 23, 2017

    @tunnckoCore
    tunnckoCore
    on Feb 23, 2017
    Collaborator
    More actions

    I'm agree with you and was thinking the same thing when mitt came - in its case we can get few more features if we allow 20-30bytes more, but @developit is holding strongly that it should be 200b. I'm agree with him too and there was a discussion like if we allow such things we'll get to point such as "let's add more more 1-2kb" haha and was mentioned momentjs that it started like micro lib.

    So yea, it is good thing to try to be strict.

  4. farskid commented on Feb 23, 2017

    @farskid
    farskid
    on Feb 23, 2017
    Author
    More actions

    @tunnckoCore HAHA did not know that momentjs was a micro library at the beginning. Looking forward to hear about the decision from @developit . This feature whether added or not, both seems logical to me at the moment. :)

  5. tunnckoCore commented on Feb 23, 2017

    @tunnckoCore
    tunnckoCore
    on Feb 23, 2017
    Collaborator
    More actions

    Yea, that's the exact comment developit/mitt#11 (comment), and i'm totally agree with him.

    Reacted by Farzad Yousefzadeh
  6. developit commented on Feb 23, 2017

    @developit
    developit
    on Feb 23, 2017
    Owner
    More actions

    This discussion makes me happy :)
    Let's keep this on a list of nice-to-haves that we can look to if we save bytes.

    Btw - for defaults, we should make a wrapper library, that way they would work for native fetch too 😀

    Reacted by Charlike Mike Reagent, Tucker Whitehouse, Paul Martin and Jason
    Reacted by Farzad Yousefzadeh
  7. farskid commented on Feb 23, 2017

    @farskid
    farskid
    on Feb 23, 2017
    Author
    More actions

    @developit You mean like an IIFE that wraps the native or unfetch altogether?

  8. developit commented on Feb 23, 2017

    @developit
    developit
    on Feb 23, 2017
    Owner
    More actions

    Yup, a way to inject defaults by proxying window.fetch:

    let real = window.fetch;
    window.fetch = (url, options) => {
      // Apply URL and options transforms here
      return old(url, ootions)
        .then(options.after || Object);
                   // ^ middleware!!
    };
  9. farskid commented on Feb 23, 2017

    @farskid
    farskid
    on Feb 23, 2017
    Author
    More actions

    Yeah, good pattern, agreed.

    Reacted by Charlike Mike Reagent
  10. tunnckoCore commented on Feb 23, 2017

    @tunnckoCore
    tunnckoCore
    on Feb 23, 2017
    Collaborator
    More actions

    Absolutely agree to be separate kinda nanolib. Hm, let's coin nano frameworks? haha

  11. developit commented on Feb 24, 2017

    @developit
    developit
    on Feb 24, 2017
    Owner
    More actions

    Unlibs

    Reacted by Charlike Mike Reagent, Simon Buerger, Jad Joubran, Max Milton, Jonas Theodor and Jason
  12. developit
    added
    possible-addon
    on Feb 25, 2017
  13. developit commented on Feb 25, 2017

    @developit
    developit
    on Feb 25, 2017
    Owner
    More actions

    @tunnckoCore @farskid - what do we want to do with these types of issues/PRs? We can't merge them because of the nature of this library (it being a polyfill and thus bound by the spec it emulates), but I hate closing them when there's good discussion and tasks to be taken away. Maybe we need a repo/place where these ideas/implementations go so that we can build up a set of feature requests for wrapper libraries?

    Reacted by Charlike Mike Reagent
  14. farskid commented on Feb 26, 2017

    @farskid
    farskid
    on Feb 26, 2017
    Author
    More actions

    @developit @tunnckoCore I guess a wrapper for addon features is a nice idea. Devs can either use the super light version or pay the price of not so much light version for the extra features such as global configurations, extra handlers, ...

  15. developit commented on Feb 26, 2017

    @developit
    developit
    on Feb 26, 2017
    Owner
    More actions

    Exactly! And the wrapper will work regardless of whether unfetch or native fetch gets used.

    Reacted by Charlike Mike Reagent
  16. farskid commented on Feb 26, 2017

    @farskid
    farskid
    on Feb 26, 2017
    Author
    More actions

    Yup so much like a higher order API. Would love to contribute to the wrapper.

    Reacted by Charlike Mike Reagent and Jason Miller
  17. tunnckoCore commented on Feb 26, 2017

    @tunnckoCore
    tunnckoCore
    on Feb 26, 2017
    Collaborator
    More actions

    Exactly, that's the cool of micro things. : )

    Reacted by Farzad Yousefzadeh and Jason Miller
  18. developit commented on Feb 26, 2017

    @developit
    developit
    on Feb 26, 2017
    Owner
    More actions

    Prior art:
    https://github.com/RickWong/fetch-plus

  19. notpushkin commented on Mar 10, 2017

    @notpushkin
    notpushkin
    on Mar 10, 2017
    More actions

    I've written this in one of my projects sometime ago. fetch-plus seems a lot nicer though.

  20. developit commented on Mar 10, 2017

    @developit
    developit
    on Mar 10, 2017
    Owner
    More actions

    @iamale totally stealing that

  21. MobiusHorizons commented on Mar 22, 2017

    @MobiusHorizons
    MobiusHorizons
    on Mar 22, 2017
    More actions

    Learned a lot just reading this thread!! There are a lot of good ideas happening here. Is there a way it can be preserved? If it were closed, it could still be linked to from a wiki or something.

  22. developit commented on Mar 22, 2017

    @developit
    developit
    on Mar 22, 2017
    Owner
    More actions

    Heh - I think that's why we haven't closed it. Need to find a good home for these things, maybe in the wiki.

  23. notpushkin commented on Apr 3, 2017

    @notpushkin
    notpushkin
    on Apr 3, 2017
    More actions

    Another thing that I had in mind since I wrote arequests is this:

    const api = Afetch({url: "https://api.github.com"});
    let mdo = await api.users["mdo"].get();
    let json = await mdo.json();  // or whatever you'd do with a regular Fetch object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    possible-addon

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.