Answer the question
In order to leave comments, you need to log in
How to track all outgoing JS requests?
How can you track all outgoing requests for JS? I need to catch a 503 error on the response. Walking through all requests and prescribing if (err === 503) is not a variant. It needs to be done somewhere in one place. It should be some kind of addEventListener type watcher on the entire document, which will see that the request has been completed, even if the page is already loaded, and inside I could check the status of the response.
PS I need to check for statuses in the code, in JS. On what specific endpoints the request is made, I also do not know.
Answer the question
In order to leave comments, you need to log in
I need to catch a 503 error on the response. Walking through all requests and prescribing if (err === 503) is not a variant.
To do this, you need to intercept all fetch and xhr requests,
Here is a mini-library that will help with this:
https://gist.github.com/benjamingr/0433b52559ad61f...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question