I have an api method which works and returns an int type. I am trying to convert get response to angular number:
This is what I am doing now:
Request to api:
GetNumberOfPages(topValue: number, companyNamePattern: string) {
return this.http.get<number>(apiUrl + '/getNumberOfPages?topValue=' + topValue +
'&companyNamePattern=' + companyNamePattern, httpOptions)
.pipe(
tap(v => console.log('GetNumberOfPages complete')),
catchError(this.handleError('GetNumberOfPages', []))
);
}
usage in component:
getNumberOfPages(topValue, companyNamePattern) {
var numberOfPagesAny: any;
this.api.GetNumberOfPages(topValue, companyNamePattern).subscribe(n => numberOfPagesAny = n);
this.numberOfPages = parseInt(numberOfPagesAny, 10);
console.log(this.numberOfPages + " number")
console.log(numberOfPagesAny + " any")
}
But whatever I try I can't get the value:
So how to convert get response to number?