如何将 http 调用的输出作为输入传递给 Rx JS 中的另一个 http 调用?
How can I pass the output of an http call as input to another http call in Rx JS?
您好,当我尝试执行以下操作时出现错误
export class FlightFormTemplatesStepComponent
{
tagonMessagePrefix: TagOnMessagePrefix;
ngOnInit() {
this.flightService.get(this.flightId).pipe(
tap (flight => {this.flight = flight}),
mergeMap( (flight) => {
return this.flightService.getTagonMessagePrefix(flight);
})
).subscribe(
(tagonMessagePrefix) => { this.tagonMessagePrefix = tagonMessagePrefix}
);
}
}
这是我收到的错误。
property) FlightFormTemplatesStepComponent.tagonMessagePrefix: TagOnMessagePrefix
Type '{}' is missing the following properties from type 'TagOnMessagePrefix': id, flightName, flightTagonTypes, configuredGlobalTagonSettings, tagonTextts(2739)
知道我该如何解决这个问题
我改为地图操作,它有效
this.flightService.get(this.flightId).pipe(
tap (flight => {this.flight = flight}),
switchMap( (flight) => {
return this.flightService.getTagonMessagePrefix(flight);
})
).subscribe(
(tagonMessagePrefix:TagonMessagePrefix) => { this.tagonMessagePrefix = tagonMessagePrefix}
);
您好,当我尝试执行以下操作时出现错误
export class FlightFormTemplatesStepComponent
{
tagonMessagePrefix: TagOnMessagePrefix;
ngOnInit() {
this.flightService.get(this.flightId).pipe(
tap (flight => {this.flight = flight}),
mergeMap( (flight) => {
return this.flightService.getTagonMessagePrefix(flight);
})
).subscribe(
(tagonMessagePrefix) => { this.tagonMessagePrefix = tagonMessagePrefix}
);
}
}
这是我收到的错误。
property) FlightFormTemplatesStepComponent.tagonMessagePrefix: TagOnMessagePrefix
Type '{}' is missing the following properties from type 'TagOnMessagePrefix': id, flightName, flightTagonTypes, configuredGlobalTagonSettings, tagonTextts(2739)
知道我该如何解决这个问题
我改为地图操作,它有效
this.flightService.get(this.flightId).pipe(
tap (flight => {this.flight = flight}),
switchMap( (flight) => {
return this.flightService.getTagonMessagePrefix(flight);
})
).subscribe(
(tagonMessagePrefix:TagonMessagePrefix) => { this.tagonMessagePrefix = tagonMessagePrefix}
);