Sorry 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.
You can use Object.assign to merge headers conditionally.
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.
Not working as i am trying the same
Not working as i am trying the same
@stoffern Maybe late but be sure that your WAF is not filtering custom headers.
Very late :D i solved it somehow 馃殌
Most helpful comment
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.