[fetch] FormData feature support detection broken
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.
Same issue with that, support.formData and support.blob always false, but both FormData, Blob and FileReader exist in windows.
I'm having this same issue. You are right about self.fetch being the issue
I am having the same issue, @oblador 's fix solved the problem.
This would be a great fix to merge
:+1: 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.
I'm having the same issue as well. @oblador's fix also worked for me.
My PR was recently merged, so I'm closing this issue.