cferdinandi / atomic

A tiny, Promise-based vanilla JS Ajax/HTTP plugin with great browser support.
MIT License
540 stars 78 forks source link

When Object is passed, content-type is form-urlencoded #73

Closed brandonkal closed 5 years ago

brandonkal commented 5 years ago

When an object is passed, the content type should be transparently set to JSON yet it is: "application/x-www-form-urlencoded" This causes objects that contain other objects to be converted to the "[object Object]" string.

cferdinandi commented 5 years ago

This is a configurable option. Can't you change that when passing in your data?

brandonkal commented 5 years ago

Yes. It works perfectly fine when setting the option. It just seemed like a nice option when the input data is detected as an object.

cferdinandi commented 5 years ago

I don't think you can presume that passing in an object means they want the type to be JSON.

Folks will sometimes pass in objects that need to be stringified before sending to an API endpoint, for example.