azure-contrib / node-azure-search

A JavaScript client library for the Azure Search service, which works from either from Node.js or the browser
42 stars 28 forks source link

Way to add headers to POST requests #34

Closed alonisser closed 6 years ago

alonisser commented 6 years ago

Following the docs, a recommended way of tracking requests is adding headers But following the code search method uses post method which does not pass overriders to execution function, which is the way to pass headers. Is there a work around this ? A recommended technical design for a PR?

richorama commented 6 years ago

Good point.

I think adding additional headers on the options object in the module's constructor is the most simple solution.

The only problem is that you'll need to create a new instance of the search client when you want a new value for the header.

To clarify, I mean this:

var client = AzureSearch({
  url: "https://XXX.search.windows.net",
  key: "YYY",
  headers : { "x-my-custom-header" : "foo"  }
});