Comments (5)
It should be possible to override the headers
object for those cases where you need to do something special. Let me know if that's not sufficient and we can reopen.
from backbone.fetch.
That's sort of the issue.
By overriding the headers to have a content type of "multipart/form-data," the server errors that the multipart boundary can't be found.
This seems to be an issue with how fetch itself works, based on other's experiences. The recommendation is to take the content-type out of the headers and let the browser generate it.
It's interesting because when I set the content-type to undefined I expect the defaults function to override it with 'application/json', but it comes through as a string e.g. - "content-type": "undefined". This might have to do with the way backbone's sync method works, but I still imagine that if the content-type header did come through as undefined, the defaults method would still override it.
Any ideas?
from backbone.fetch.
Unfortunately with the defaults function there's no nice way to remove a key, only override it. Maybe try with an empty string, or null
?
It looks like fetch
(or at least the fetch polyfill) has its own logic for when the content-type header is falsey. (I think this is the section in the spec, so should work in native implementations too).
from backbone.fetch.
Thanks for your help!
I tried the above. I don't quite understand why falsey values are being quoted/literalized when I inspect the request object from node - using the fetch polyfill it correctly sets the content-type/boundary, but chrome v55 doesn't. Fetch seems cool, but I think i'll just switch back to jQuery for now.
Thanks again
from backbone.fetch.
Sure, sorry to hear it.
Maybe as a last option, pass an headers
object instead of trying to set the content-type
directly? Should work. Otherwise if you can think of a good solution it might help the next person too.
from backbone.fetch.
Related Issues (2)
- Can't catch error HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from backbone.fetch.