Sometimes I have trouble to fetch my data using $http service. And I did not 100% understand the main difference between .success() and .then()
The following is an examp
As per the documentation: https://docs.angularjs.org/api/ng/service/$http
The .then() function is the standard way to register callbacks for when a promise has been resolved - see https://docs.angularjs.org/api/ng/service/$q for angular's implementation of promises.
The promise returned by $http is a promise for a Response:
$http.get('http://example.com').then(function successCallback(response) {
response.data, response.status, and so on
})
Oftentimes, all you need from the Response is just the data. The callbacks registered via .success() will receive just data:
$http.get('http://example.com').success(function successCallback(data) {
data.??? depending on what you return
})