How to convert Promise to Observable in Angular?

How to convert Promise to Observable in Angular?

Angular by default returns Obserable when you invoked HTTP client methods. But let’s assume that you have a function that returns a promise. In this case, you can easily change the return type from Promise to Observable .

In order to do this first import from operator from ’rxjs and wrap the promise in the from the operator.

import { from } from  'rxjs';
const observable = from(promise);

Please do not post any spam link in the comment box😊

Post a Comment (0)
Previous Post Next Post