greencatsoft / scalajs-angular

AngularJS Binding for Scala.js
Apache License 2.0
252 stars 42 forks source link

HTTP success, error deprecated #100

Closed axos88 closed 7 years ago

axos88 commented 7 years ago

https://code.angularjs.org/1.5.9/docs/api/ng/service/$http

The $http legacy promise methods success and error have been deprecated. Use the standard then method instead. If $httpProvider.useLegacyPromiseExtensions is set to false then these methods will throw $http/legacy error.

mackler commented 7 years ago

I was just updating some of my code to accommodate this deprecation. Looking at the definition of this() I see the type of the "success" function is js.Function1[T, T] where T is the type of the HTTP request entity. But according to this migration guide as well as my own experimentation, it seems that the success function, rather than being passed a value of type T is passed a value of type HttpResult, which in turn has a member named data.

Am I confused or is the definition of this() incorrect?

mysticfall commented 7 years ago

Closing, as it's fixed with #101. (Thanks, @axos88!)

@mackler You are correct about the return type being HttpResult, and it's the reason why we have a separate HttpPromise, which is just an alias for Promise[HttpPromise[T]].