I am trying to get a simple string from my database using an Observable. I've done it like this before and haven't had any problems.
Configuration is a simple object with just an id: number
and a name: string
.
I'm calling this function from a ForkJoin.
Here is my code:
private getMaxSeconds() {
let maxSeconds = this.configurationRemoteService.get('MAX_SECONDS_VIDEOGRAMMETRY_SMALL')
.subscribe(config => {
maxSeconds = config.value;
}, error => console.log(error));
return maxSeconds;
}
ForkJoin code(reduced version):
forkJoin([
this.getMaxSeconds(),
]).subscribe(response => {
this.MaxSeconds= response[0] as string;
});
But this time, I'm getting this error:
Type 'string' is not assignable to type 'Subscription'.
The only difference is that now I am declaring the variable with let in the function.
How can I convert or parse this Suscription
into a string
?
I'm using TypeScript 4, Angular 8 and Laravel 4 for the API.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…