在发送其他http请求之前发送http请求angular 2

时间:2016-11-16 13:08:34

标签: angular angular2-http angular2-jwt

我需要通过http模块获取jwt令牌,然后在头中使用此令牌发出其他请求。如何延迟应用程序初始化直到令牌获取请求被解决?

1 个答案:

答案 0 :(得分:1)

this.http.get(...)
.map(response => response.json())
.flatMap(response => this.http.get(...).map(response => response.json())
.subscribe(response => this.result = response);

您可以使用How to pass parameters rendered from backend to angular2 bootstrap method来延迟应用初始化。

相关问题