-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
global default options and handlers #22
Comments
Sounds good, but don't believe we can get 500b, haha |
Well, having a useful feature to cost some bytes wouldn't harm I guess. |
I'm agree with you and was thinking the same thing when So yea, it is good thing to try to be strict. |
@tunnckoCore HAHA did not know that |
Yea, that's the exact comment developit/mitt#11 (comment), and i'm totally agree with him. |
This discussion makes me happy :) Btw - for defaults, we should make a wrapper library, that way they would work for native fetch too 😀 |
@developit You mean like an IIFE that wraps the native or unfetch altogether? |
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!!
}; |
Yeah, good pattern, agreed. |
Absolutely agree to be separate kinda nanolib. Hm, let's coin |
Unlibs |
@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? |
@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, ... |
Exactly! And the wrapper will work regardless of whether unfetch or native fetch gets used. |
Yup so much like a higher order API. Would love to contribute to the wrapper. |
Exactly, that's the cool of micro things. : ) |
Prior art: |
I've written this in one of my projects sometime ago. |
@iamale totally stealing that |
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. |
Heh - I think that's why we haven't closed it. Need to find a good home for these things, maybe in the wiki. |
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.
The text was updated successfully, but these errors were encountered: