【发布时间】:2023-03-30 04:10:01
【问题描述】:
有人知道 alpha 45 和 alpha 48 之间的 http 是否有任何重大更改?我一直在四处寻找,但没有找到任何东西。我的问题是下面的代码在 Alpha 45 上运行良好。但是现在我已经升级到 Alpha 48,当我尝试运行应用程序时,我收到了 _this.http.post(...).map is not a function 错误消息。奇怪的是,IntelliSense 显示 http.post 正在返回一个 observable。这意味着地图功能应该可用。任何帮助,将不胜感激。谢谢!
public Authenticate(username: string, password: string): Observable<boolean> {
this.ResetAuthenticationValues();
return Observable.create((subscriber: EventEmitter<string>) => {
let body: string = 'grant_type=password&username=' + username + '&password=' + password;
let headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded');
this.http.post('http://example.com', body, {headers: headers})
.map(res => res.json())
.subscribe(
(data: DataResponse) => {
if (!data.error) {
this.accessToken = {access_token: data.access_token, token_type: data.token_type};
subscriber.next(this.isAuthenticated = true);
}
else
subscriber.error(this.isAuthenticated = false);
},
(err) => subscriber.error(err),
() => subscriber.complete()
);
return () => { };
});
}
【问题讨论】:
-
坚持使用 alpha 47。他们是 discussing 如何将 angular2 与 RxJS 一起发布。
标签: typescript angular rxjs