I want to find a way to cancel request after it is sent.
my status: I want to cancel a uploading file, so I must to stop this request.
I look a lot of pages , only I can find is stop before request.
It is not suitable for me.
ive been stuck for more than 3 days looking for an answer...
You should be able to do that based on the https://github.com/pagekit/vue-resource/blob/master/docs/recipes.md#abort-a-request recipe. A reference to the last request is stored on your component:
before(request) {
// set previous request on Vue instance
this.previousRequest = request;
}
so just add a new method to cancel the request:
methods: {
cancelUpload: function () {
this.previousRequest.abort();
}
}
and a button that calls this method.
You solved my problem.
@danmichaelo 锛寉ou are so nice. thx
Most helpful comment
You should be able to do that based on the https://github.com/pagekit/vue-resource/blob/master/docs/recipes.md#abort-a-request recipe. A reference to the last request is stored on your component:
so just add a new method to cancel the request:
and a button that calls this method.