Cancel of requests through saga
const cancelSource = axios.CancelToken.source()try { yield all([ call(axios.get, "/api/1", { cancelToken: cancelSource.token }), call(axios.get, "/api/2", { cancelToken: cancelSource.token }), /// ... ])} finally { if (yield cancelled()) { yield call(cancelSource.cancel) }}
If someone is interested in a working solution to this exact problem, I am creator of redux saga library addon specifically to those kind of problems - https://github.com/klis87/redux-saga-requests
It does those kind of things automatically for you - if a saga in cancelled, request is aborted automatically, so you dont even need to think about it.
The top answer helped me, however, I had to use this call
yield call(cancelSource.cancel)