js]1 say that it is possible to cancel networkrequest (this is about componentWillUnmount()
method):
Perform any necessary cleanup in this method, such as invalidating timers, canceling network requests, ...
But answers here say it is not possible.
Question being, is it possible or not to cancel a network requests in JS?
For example. I started setInterval
with requests using fetch
API in componentDidMount
. On some condition I want to stop requests. I want to do so in componentWilUnmount
. So how can I cancel all network requests?
I'm not talking about calling clearInterval
which will stop setInterval
. I want to make sure that any network requests that were started will be canceled in a given condition.