Wulf Wulf - 4 months ago 5x
Javascript Question

AngularJS Why use $q.all() on one promise?

I'm familiarizing myself with a codebase, and I'm seeing this everywhere:


This does not make sense to me -- I've read the documentation, and I don't know why the following is not used instead, since it's already one promise...


Is there something I'm missing? What's the advantage of the former over the latter?


Yes, this is a bit weird, but there is a difference: responseFunc will be called with an array of the result instead of the result itself.

This probably should better be written as either

promise.then(res => responseFunc([res]))