Is there a way to abort a get request manually? #1416
-
Hi, Is there a way to abort a GET request when using lazy query? const [trigger, { data, refetch, isFetching }] = useLazyGetPokemonByNameQuery(); Context: The API I am working with could take a while to fulfill the request (over a few minutes in some cases). I am planning to give user a way of cancelling the current request. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
In theory you might be able to call
but I'm not 100% sure. We have general cancellation support in RTKQ, but it is not really part of types and documentation because it is very unclear what would happen after cancellation from a developer experience side - the request would go into a weird "error" state. This needs more fleshing out. Generally in most cases it does not make a difference though: cancelling does not stop most servers from actually processing it and if you're not interested in the result, it could also just be ignored. Your very-long-running-request here seems to be quite the difference from that "normal case" 🤔 |
Beta Was this translation helpful? Give feedback.
In theory you might be able to call
but I'm not 100% sure.
We have general cancellation support in RTKQ, but it is not really part of types and documentation because it is very unclear what would happen after cancellation from a developer experience side - the request would go into a weird "error" state. This needs more fleshing out.
Generally in most cases it does not make a difference though: cancelling does not stop most servers from actually processing it and if you're not interested in the result, it could also just be ignored. Your very-long-running-request here seems to be quite the difference from that "normal case" 🤔