Angular HttpPromise: difference between `success`/`error` methods and `then`’s arguments


According to AngularJS doc, calls to $http return the following:

Returns a promise object with the standard then method and two http specific methods:success and error. The then method takes two arguments a success and an error callback which will be called with a response object. The success and error methods take a single argument – a function that will be called when the request succeeds or fails respectively. The arguments passed into these functions are destructured representation of the response object passed into the then method.


The major difference between the 2 is that .then() call returns a promise (resolved with a value returned from a callback) while .success() is more traditional way of registering callbacks.

Promise-based callbacks (.then()) make it easy to chain promises (do a call, interpret results andthen do another call, interpret results, do yet another call etc.).

The .success() method is a streamlined, convenience method when you don’t need to chain call nor work with the promise API (for example, in routing).

In short:

  • .then() – full power of the promise API but slightly more verbose
  • .success() – doesn’t return a promise but offeres slightly more convienient syntax


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s