question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fetch request is always sent with Accept: application/json header

See original GitHub issue

Describe 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:open
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ferdikoomencommented, Dec 16, 2020

@iansan5653 good point, will fix this in the next mayor release

0reactions
ferdikoomencommented, Jan 25, 2022

@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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found