Vue-resource: Finalize

Created on 25 Apr 2016  路  5Comments  路  Source: pagekit/vue-resource

Is there a way to add a method that will always be called when success or error? Like Exceptions have finalize.

I want to stop the button loading spinner in any case.

Most helpful comment

Heres an example:

new Vue({

    ready: function() {

      // GET request
      this.$http({url: '/someUrl', method: 'GET'}).then(function (response) {
          // success callback
      }, function (response) {
          // error callback
      }).finally(function () {
          // finally callback      
      });

    }

})

All 5 comments

Yes, you can use finally(callback)

How?

Heres an example:

new Vue({

    ready: function() {

      // GET request
      this.$http({url: '/someUrl', method: 'GET'}).then(function (response) {
          // success callback
      }, function (response) {
          // error callback
      }).finally(function () {
          // finally callback      
      });

    }

})

Thanks

I want to have response object in finally callback. I am getting undefined

Was this page helpful?
0 / 5 - 0 ratings