react-refetch icon indicating copy to clipboard operation
react-refetch copied to clipboard

can't post multipart/form-data

Open zhouchengcom opened this issue 9 years ago • 4 comments

zhouchengcom avatar Aug 23 '16 07:08 zhouchengcom

@connect( props => ( { newProject: data => ( { newProjectRespond: { url: '/new', method: 'POST', body: data, force: true, headers: { 'Content-Type': 'multipart/form-data'} } })}) )

and then ‘const data = new FormData() this.props.newProject( data )’ but post data miss boundary= just like this content-type:multipart/form-data

zhouchengcom avatar Aug 23 '16 07:08 zhouchengcom

This is likely an issue with your fetch library. Can you try it directly without refetch and see if it works?

ryanbrainard avatar Aug 23 '16 08:08 ryanbrainard

raw fetch is ok I found the right way is set headers: { 'Content-Type': null } :)

zhouchengcom avatar Aug 23 '16 08:08 zhouchengcom

Ah, makes sense (kind of). Since this is still probably fetch library dependent, I'm hesitant to document it, but perhaps a note in the docs would help someone else not run into this same issue.

ryanbrainard avatar Aug 23 '16 09:08 ryanbrainard