Docs bug: How to intercept *all* requests to x
See original GitHub issueHere is what I see in the README:
var scope = nock('http://www.google.com')
.get('/cat-poems')
.reply(function(uri, requestBody) {
console.log('path:', this.req.path);
console.log('headers:', this.req.headers);
// ...
});
I am looking for something like this:
var scope = nock('http://www.google.com')
.all()
.reply(function(uri, requestBody) {
});
or like this?
var scope = nock('http://www.google.com')
.get('*')
.post('*')
.put('*')
.head('*')
.reply(function(uri, requestBody) {
});
how do I setup a single handler that can intercept all requests to google.com
? Seems like a common problem and I don’t see anything in the docs.
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
intercept - Cypress Documentation
Spy and stub network requests and responses. Tip: We recommend you read the Network Requests guide first. All intercepts are automatically cleared before....
Read more >Intercept HTTP requests - Mozilla - MDN Web Docs
To intercept HTTP requests, use the webRequest API. This API enables you to add listeners for various stages of making an HTTP request....
Read more >Spring Boot Adding Http Request Interceptors - Stack Overflow
I have followed this way to intercept the signup requests come to my application in order to do some common validations. But the...
Read more >Setting up Axios Interceptors for all HTTP calls in an application
Interceptors are a feature that allows an application to intercept requests or responses before they are handled by the .then() or the .catch() ......
Read more >Advanced Usage — Requests 2.28.1 documentation
Any dictionaries that you pass to a request method will be merged with the session-level values that are set. The method-level parameters override...
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 Free
Top 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
My original use case was for a proxy server, which would intercept everything, but what I had in mind changed, so I ended up using something very different so I never fully explored the nock API beyond this question.
@ORESoftware does the above code work for you?
I could see how a
.all()
or.any()
method would be helpful. The proper way would probably be to use lower-level APIs to intercept all requsets, it’s something we want to work on now. @n30n0v already created an interceptor library, maybe it’s a better solution for your case: https://github.com/n30n0v/nock-interceptorCould explain your use case? Maybe there is a better solution to it than intercepting all requests?
@jlilja We will probably redo the README soon, it might be good to add a section that answers how to intercept all requests, so we incorporate it in the new documentation?