-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Automatically pull headers from node-form-data. #31
Conversation
Hi, thx for the PR, but I don't think So really we are making a special case for Any reason you have to do this instead of passing headers separately? |
I understand that it is a bit specific to Currently I have to write code something like this to make it work isomorphically. form = new FormData();
form.append("file", file);
// Check if I am on the server :(
if (!process.browser) {
headers = form.getHeaders();
for (field in headers) {
options.headers[field] = headers[field];
}
}
// Use node-fetch with options It would be awesome if this small exception could be added (similar to supporting streams) to allow for a nice serverside (form-data) experience that also works in the browser. |
Alright I get your use-case here, here is my understanding:
I will take the PR, as I see no better solution to detect FormData reliably on node.js |
Automatically pull headers from node-form-data.
PS: to clarify my personal stand on isomorphic javascript, I think it can be misleading to developers who thinks the code just works both client-side and server-side, when the truth is far from it (what we are doing is a good example of such problem). |
released as v1.3.2, thx for your work. |
Thanks a lot for your work to get this merged and released so quickly. I understand your viewpoint (that devs should realize that the code on the server is often different from the client). Personally I think that this is explained well in both node-fetch and node-form-data and that users of both understand that they work with native node modules under the hood and expose some api differences (Streams and such). I am glad to see this merged as both libraries together act as a great (complete), abstraction for isomorphic fetching. |
This is convenient for isomorphic apps that rely on form-data.