Skip to content
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

[fetch] FormData feature support detection broken #2376

Closed
oblador opened this issue Aug 18, 2015 · 7 comments
Closed

[fetch] FormData feature support detection broken #2376

oblador opened this issue Aug 18, 2015 · 7 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@oblador
Copy link
Contributor

oblador commented Aug 18, 2015

I'm trying to post multipart files with fetch in RN 0.9.0 with something similar to this:

var formdata = new FormData();
formdata.append('image', this.state.image); // From camera roll or whatever
fetch('http://…', { method: 'POST', body: formdata });

It fails because the FormData feature detection always fails, more specifically 'FormData' in self on line 165 @ fetch.js. If I change self to window it works as expected, but somehow that feels too easy. I'm happy to send a PR or for someone to tell me why it's a bad idea.

@apolkingg8
Copy link

Same issue with that, support.formData and support.blob always false, but both FormData, Blob and FileReader exist in windows.

@peterpme
Copy link

peterpme commented Sep 4, 2015

I'm having this same issue. You are right about self.fetch being the issue

@jhau
Copy link

jhau commented Sep 7, 2015

I am having the same issue, @oblador 's fix solved the problem.

@jim-lake
Copy link

jim-lake commented Sep 9, 2015

This would be a great fix to merge

@despairblue
Copy link
Contributor

👍 definitely, at the moment I need to use template strings for the body.

One thing to consider is that fetch is pulled in from github/fetch, meaning if it's updated in the future, all changes local to this repo are lost and would have to be reapplied.

Probably better to include it there, though they seem reluctant to include it. On the other hand, maybe fetch was only initially imported and is now maintained by the react-native team.

@slooker
Copy link

slooker commented Sep 22, 2015

I'm having the same issue as well. @oblador's fix also worked for me.

ghost pushed a commit that referenced this issue Sep 22, 2015
Summary: This PR bumps fetch to 0.9.0, the latest release and fixes broken feature detection originating in that self is not referring to `window.self` but an empty object. Assigning that object to window.self or GLOBAL won't work in the chrome dev tools because of CORS restrictions. This is a pragmatic solution but maybe not ideal.

Background to the problem can be read here: #2376
Closes #2587

Reviewed By: @​trunkagent, @​svcscm

Differential Revision: D2438341

Pulled By: @vjeux
@oblador
Copy link
Contributor Author

oblador commented Sep 23, 2015

My PR was recently merged, so I'm closing this issue.

@oblador oblador closed this as completed Sep 23, 2015
MattFoley pushed a commit to skillz/react-native that referenced this issue Nov 9, 2015
Summary: This PR bumps fetch to 0.9.0, the latest release and fixes broken feature detection originating in that self is not referring to `window.self` but an empty object. Assigning that object to window.self or GLOBAL won't work in the chrome dev tools because of CORS restrictions. This is a pragmatic solution but maybe not ideal.

Background to the problem can be read here: facebook#2376
Closes facebook#2587

Reviewed By: @​trunkagent, @​svcscm

Differential Revision: D2438341

Pulled By: @vjeux
@facebook facebook locked as resolved and limited conversation to collaborators Jul 21, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

8 participants