matthew-andrews / isomorphic-fetch

Isomorphic WHATWG Fetch API, for Node & Browserify
MIT License
6.95k stars 288 forks source link

IE11 throws exception if PUT responds with error #74

Open Pongetti opened 8 years ago

Pongetti commented 8 years ago

Hello,

I'm getting a strange error in IE 11. It occurs only if all 3 of these are true: -method = PUT -I return an error from my server, such as a 400 Bad Request -I have included contents in the Body of my request

SCRIPT7002: XMLHttpRequest: Network Error 0x2efe, Could not complete the operation due to error 00002efe .

Under the network tab of the debugger, the request will show as PENDING forever.

I had thought it may be an issue with my server's response but I've forced my server to respond with the exact same error for a POST request and everything works as normal.

Code is below. Let me emphasize that if I remove the body from the options, it works as normal.

    fetch ('/api/resource/1/', {
            method: 'put',
            credentials: 'same-origin',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json; charset=utf-8',
                'X-CSRFToken': Cookies.get('csrftoken')
            },
            body: '{"a":"b"}'
    })

Any idea what's going on? I suspect there's something going on with the charset since adding utf-8 seems to be a common solution to that error message in general and it doesn't occur without a body. The fact I can't duplicate with a POST though makes me think the error may be in fetch rather than on my end.

Thanks for the help!