[Vuejs]-Vuejs2 cancel http requests on route navigate

2👍

You could try something like this:

let ongoingRequest
export default {
    beforeDestroy() {
        ongoingRequest.abort()
    },
    methods: {
        getdata() {
            this.$http.get("users", {
                before(request) {
                    ongoingRequest = request
                }
            }).then((res) => {
                ///do stuff with returned data
            })
        }
    }
}

I found an issue talking about that here.

👤mtflud

Leave a comment