I'm trying to get an object from a request but get an error.
user.service.ts
:
async obtainUser(user_id: string): Promise<User> {
return await this.httpClient.get<User>(requestUrl).toPromise().then((res) => {res});
}
user.componenet.ts
:
var user = <User>this.userService.obtainUser(user_id);
console.log(user);
The error is:
error TS2352: Conversion of type 'Promise<User>' to type 'User' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
industrialareas_angular_ctnr | Type 'Promise<User>' is missing the following properties from type 'User': id, fiscal_id, first_name, last_name, and 9 more.
Can anybody help me?