2

I would like to create a global request interceptor for request-promise based requests so that I can add an x-request-id header to all outgoing requests. Since the behaviour is common across all outgoing requests, I prefer to not have to add this functionality everywhere that I am making a request.

I don't notice such functionality in the library documentation.

Sunil Garg
  • 14,608
  • 25
  • 132
  • 189
Richard Collette
  • 5,462
  • 4
  • 53
  • 79

1 Answers1

1

You are looking for request.defaults()

Engineer
  • 47,849
  • 12
  • 88
  • 91
  • I didn't realize I had access to all the normal request methods. The downside here is that if I am using RP in many modules, I will have to create and provide access to this wrapped instance across all modules. It's a shame that the RP global instance (static) can't be set (without monkey patching or something). – Richard Collette May 16 '17 at 19:14
  • You can open an issue in github repo, maybe the contributors and/or you can add your desired functionality. Why not ?! – Engineer May 17 '17 at 13:59