You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the issue
What is the difference between timeout and cancelToken? Does it mean that I only need to use one of them?
Example Code
use CancelToken
letsource=CancelToken.source();setTimeout(()=>{source.cancel();},3000);returnaxios.get(ip+'/config',{cancelToken: source.token}).then((result)=>{// My logic})
Timeout and canceltoken have different use cases. Timeout is really just for request timeouts. Canceltoken is used for any other reasone to cancel a request, like an user interaction.
@TheNoim@xiaobitipao
Can you share an example on how to cancel a service request on user interaction.
scenario:
user'll be calling the same service asynchronously when a new request for the service is triggered the existing service request should cancel and returns only the new response
Thanks!
Describe the issue
What is the difference between timeout and cancelToken? Does it mean that I only need to use one of them?
Example Code
use CancelToken
use timeout
Expected behavior, if applicable
I think the results of the above two pieces of code are the same. Is that so?
Environment:
Additional context/Screenshots
The text was updated successfully, but these errors were encountered: