Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Finalize #262

Closed
EmilMoe opened this issue Apr 25, 2016 · 5 comments
Closed

Finalize #262

EmilMoe opened this issue Apr 25, 2016 · 5 comments

Comments

@EmilMoe
Copy link

EmilMoe commented Apr 25, 2016

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.

@steffans
Copy link
Member

Yes, you can use finally(callback)

@EmilMoe
Copy link
Author

EmilMoe commented Apr 25, 2016

How?

@steffans
Copy link
Member

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      
      });

    }

})

@EmilMoe
Copy link
Author

EmilMoe commented Apr 28, 2016

Thanks

@amarjit-singh
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants