D
D
demidov5552020-08-18 18:49:28
Angular
demidov555, 2020-08-18 18:49:28

How to catch fetch request in interceptor?

How to catch fetch request in interceptor without using HttpClient service and process it?
Case: I have a third-party service that connects via a snippet to the js index, and in some places of the application I need to wait for a request (fetch) from this snippet, because after it I pull the method that depends on this request and then send the data to the back.
The interceptor + subject is like the norms of the solution, but apparently disappears.
load from native js would not be desirable to use. Wait through setTimeout even more so.
Maybe you know the solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2020-08-19
@demidov555

You can replace the global fetch with your wrapper, and execute the code you need in it, i.e. execute the original fetch inside and call your functions after it.
But maybe it’s worth looking at the snippet itself, maybe it has some normal events?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question