Closed cryptiklemur closed 6 years ago
Thanks for the suggestion. This feature already kind of exists! The data
phinOptions option is automatically JSON stringified if it's an object. (The Content-Type
header isn't automatically set, but that's really easy for developers to do if they'd like.)
See the phinOptions type definition for more details.
@ethanent I think the Content-Type
should be added automatically, I've just spent the last 20 minutes trying to understand why the server was ignoring my POST data...
Why close this issue? Any API sending JSON without these headers is totally wrong.
@matteocontrini @thelinuxlich Thanks for the suggestion.
As of phin@2.0.0
, the Content-Type
header is defined automatically for JSON.stringify
-ed request bodies. :)
Add support for posting/putting JSON.
Would be cool if we could just do this:
Which would set the
Content-Type
andAccepts
headers toapplication/json