如何截获所有节点请求的http请求以修改请求选项? [英] How can I intercept all node request-promise http requests to modify the request options?
本文介绍了如何截获所有节点请求的http请求以修改请求选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想为基于request-promise
的请求创建一个 global 请求拦截器,以便可以向所有传出请求添加x-request-id
标头.由于该行为在所有传出请求中都是相同的,因此我希望不必在正在发出请求的所有地方添加此功能.
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.
推荐答案
您正在寻找 request.defaults ()
这篇关于如何截获所有节点请求的http请求以修改请求选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文