Set multiple headers at once?
See original GitHub issueSorry if this has been addressed - searching came up with nothing. Unless I am missing something, looks like each custom header must be individually using .set(). It would come in very handy to be able set all headers at once as an object or array of objects. Something like this:
const headers = {"Content-Type": "application/json", "Accept": "application/json"};
// OR
const headers = [{"Content-Type": "application/json"}, {"Accept": "application/json"}];
.setAll(headers)
We have a lot of custom headers and they can be conditional on many things. Now we have to pass a superagent request object to a custom method and have it call .set() on whatever headers it wants to add based on various conditions and dependencies. It’s not the most elegant thing.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
How to set multiple headers data with XMLHttpRequest in ...
If you want to set multiple headers, then call setRequestHeader multiple times. Don't add extra arguments to the first call. Share.
Read more >Set multiple headers at once? · Issue #1225 · ladjs/superagent
We have a lot of custom headers and they can be conditional on many things. Now we have to pass a superagent request...
Read more >How to pass more than one header in a request in Rest ...
We can pass more than one header in a request in Rest Assured. A web service can accept headers as parameters while making...
Read more >How to set header for multiple APIs at once - YouTube
In this video we will discuss.1. How to set header for multiple APIs at a time.ORHow to set Header at collections level.
Read more >Add multiple headers with conditions to your WordPress site ...
Add as many headers as you like; style them out all individually, and then assign them by display conditions or user conditiosn as...
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
Hey it looks like this actually works!
.set({"Content-Type":"application/json","Accept":"application/json","Margle":"Bargle"})
Problem solved! Would be good to add to the docs I guess.
Very late 😄 i solved it somehow 🚀