Getting Observable.fromPromise is not a function and Converting circular structure to JSON error

Hi @rapropos, the service that is generating the Promise is not mine. It’s an API provided by the library I am using.

I was trying avoid it because I thought the discussion might dwell into different way. But I will put it here.

Following is the scenario:

  1. Basically, I have some REST APIs written in Java that I have deployed on Microsoft Azure cloud’s API App.

  2. Then I have something called Mobile App backend that Azure Cloud provides to implement the backend part of your mobile app. This Azure Mobile App Backend provides features like Push Notifications, Offline Sync, etc. This Mobile App Backend is implemented in Node.js.

  3. Now from my Ionic 2 mobile app, in order to call a Java REST API I need to use an Azure JS (cordova) library that is provided by Microsoft.

    a. Using this library, I need to first connect with my Mobile App Backend. This gives me an object (cloudConn in my code above).

    b. This object (in bullet #a above) provides a function called invokeMethod (or invokeApi) but they have implemented it to return a Promise. And this is what I am trying to convert into an Observable.

Note: When I just use the Promise (i.e. don’t convert into Observable) I can get the expected JSON in .then() using the .result method/property as below in my home-service.ts:

       super.invokeRestMethod(myURL, 'GET').then(
          (res) => {
            let data= res.result; 
          },
          (err) => {
            console.log('error:' + err);
          }
        );

Hope this helps.