-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Axios Post Request not firing with cancelToken #3323
Comments
Since you're using the await operator, you cancel the request after it completes |
Hi I removed the await but its still not calling. |
Everything seems to work fine const source = axios.CancelToken.source();
var formData = new FormData();
formData.append("username", "Groucho");
formData.append("accountnum", 123456);
var content = '<a id="a"><b id="b">hey!</b></a>';
var blob = new Blob([content], {type: "text/xml"});
formData.append("webmasterfile", blob);
axios.post(`https://run.mocky.io/v3/d37e9195-5474-4491-9170-cd323b0d1c39?mocky-delay=5s`, formData, {
headers: {'Content-Type': 'application/json'},
withCredentials: true,
onUploadProgress: console.log,
cancelToken: source.token,
})
.then(res => console.log(res))
.catch(thrown => {
if (axios.isCancel(thrown)) {
console.log('Request canceled', thrown.message); // Request canceled Request canceled!
}
});
source.cancel('Request canceled!') |
Hello! 👋 This issue is being automatically marked as stale because it has not been updated in a while. Please confirm that the issue is still present and reproducible. If no updates or new comments are received the issue will be closed in a few days. Thanks. |
It is not working for me also. |
Describe the issue
Hi I am calling two messages. One to create my Axios cancelToken and then one to upload a file. The upload file was working up until I added the cancelToken but I still cannot get the cancelling of the file upload to happen at all. Any ideas?
Example Code
Code snippet to illustrate your question
Create token:
Upload File:
Expected behavior, if applicable
A clear and concise description of what you expected to happen.
Environment
Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
The text was updated successfully, but these errors were encountered: