This angular error came up to me with this snippet:

The error

error TS2339: Property 'then' does not exist on type 'Observable<unknown>'

The snippet

this.userService.updateFavorites(id)
      .then(async data => {
          ....

How to fix error TS2339

The solution is to convert an Observable to a Promise  RxJS firstValueFrom & lastValueFrom

import {firstValueFrom} from 'rxjs';


firstValueFrom(this.userService.updateFavorites(id)
      .then(async (data: any) => {
           ....