setHeader Function not setting header
See original GitHub issueHey there @skellock ,
I am trying to override my default headers assigned at apisauce.create() for one specific request. I tried using the api.setHeader and api.setHeaders functions. I need to set the header to Content-Type multipart/form-data.
Ive included a screenshot of my request headers, after attempting to modify with setHeader.
var body = new FormData()
body.append(‘file’, photo)
api.setHeader({‘Content-Type’: ‘multipart/form-data’})
const response = api.put(/user/photo/${id}
, body, {headers: {‘Content-Type’: ‘multipart/form-data’}})
return response
Thanks in advance for your help!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Error: Can't set headers after they are sent to the client
The res object in Express is a subclass of Node.js's http.ServerResponse (read the http.js source). You are allowed to call res.setHeader(name, value) as ......
Read more >Node.js response.setHeader() Method - GeeksforGeeks
When headers have been set with response.setHeader(), they will be merged with any headers passed to response.writeHead(), with the headers ...
Read more >Cannot set headers after they are sent to the client in JS
The "Cannot set headers after they are sent to the client" error occurs when the server in an express.js application sends more than...
Read more >XMLHttpRequest.setRequestHeader() - Web APIs | MDN
The XMLHttpRequest method setRequestHeader() sets the value of an HTTP ... If no Accept header has been set using this, an Accept header...
Read more >Data set header - IBM
It may or may not contain data set headers. If the SYSIN data set has record ... Output Processing Section -- for advanced...
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
I was unable to reproduce the bug. Here is my test (using v1.0.2):
Console output:
Evening! I think you want
setHeaders
instead ofsetHeader
here. You can usesetHeader
but the interface is 2 strings, not an object. That where that[object Object]
is coming from.i think you can remove that line entirely looking at your code tho.