I want to do a call then get the ID from that call and use it in some code later but how do I only get the ServiceProvider number? this is what I get from my rest call:
{"mitId": 18,
"ServiceProvider": "2"}
this is my current call
GetServiceProviderId() {
var spid = this.http.get<Info>(this.rooturl + 'info', { headers: this.reqHeader})
return spid;
}
So I want to use the ServiceProvideNumber in another call but how do I only return the 2?
I ended up doing this:
GetServiceProviderId(): Observable<Info> {
return this.http.get<Info>(this.rooturl + 'info', { headers: this.reqHeader })
}
this just returns the json request I then will use pipe and flatmap to get the '2'
GetInstallation(): Observable<Installation[]> {
return this.GetServiceProviderId().pipe(
flatMap(info => {
return this.http.get<Installation[]>
(this.rooturl +
"url/?serviceproviderid=" +
info.ServiceProviderId
})
)
}
this will make the call api/url/?serviceproviderid=2