Maelstromeous / ps2alerts-website

This project has moved!
https://github.com/ps2alerts/website
GNU General Public License v2.0
10 stars 1 forks source link

Alert Detail: $http returns as a promise, no need to wrap it inside a promise #36

Closed Maelstromeous closed 8 years ago

Maelstromeous commented 8 years ago

No need to wrap a promise within a promise. $http returns a promise itself.

Maelstromeous commented 8 years ago

Investigated using the $http promise directly, it appears that $http itself, in Angular, is a promise. When the http request has been successful, it returns itself the resolve() method into the then() callback. The .then() is then passing back the successful data.

There is a function for .error() by what looks to be seemly using reject() part of promise.

In my code, I'm using a promise.all, so I can't simply return the $http promise as the all promise requires all subpromises to resolve.