Fetch request is always sent with Accept: application/json header
See original GitHub issueDescribe the bug
I have an API that has some JSON endpoints and some file endpoints (media type application/octet-stream
). The generated code works for the JSON endpoints, but for the file endpoints the server returns 406
because the code always sends the request with header Accept: application/json
.
If there is no 200
response described with media type application/json
, the generated code should use the first media type described or it should be a method parameter.
I’m using the Fetch API with version 0.7.0
.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Fetch API - Content-Type is sent as text/plain when it's set to ...
In my React app when I submit a form to create a new user I create a request to the server using fetch...
Read more >Using the Fetch API - MDN Web Docs
Supplying request options · Sending a request with credentials included · Uploading JSON data · Uploading a file · Uploading multiple files.
Read more >How to Use fetch() with JSON - Dmitri Pavlutin
In this post, I'll guide you on how to use fetch() API to load (usually using GET method) or post data (usually using...
Read more >Fetch - The Modern JavaScript Tutorial
JavaScript can send network requests to the server and load new information whenever it's needed. For example, we can use a network request...
Read more >JavaScript Fetch API Tutorial with JS Fetch Post and Header ...
// data to be sent to the POST request let _data = { title: "foo", body: "bar", userId:1 } fetch('https://jsonplaceholder.typicode.com/posts', { ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@iansan5653 good point, will fix this in the next mayor release
@scipper There is a new version that allows to create client instances to each client can have its own bearer token. You can specify the
--name
argument while generating the client. More info: https://github.com/ferdikoomen/openapi-typescript-codegen#generate-client-instance-with---name-option