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

@AaronSterling - I hear you! Guess, I need to take JavaScript more seriously and need to learn it better. :slight_smile:

If @rapropos’s suggestion doesn’t work…someday…soon…I will find a way to convert this freaking Promise into Observable and will read the result out of converted Observable! :slight_smile:

Thanks again for your much needed help and keeping your patience through my long posts. Appreciated!

That just seems insane to me. Can’t you take this thread to whoever is imposing these “environment setup restrictions” and say “nobody else on the entire planet operates this way. you are wasting a lot of your resources making me figure out a problem that may be only existing because we are ignoring over a decade of best practice on how to have web applications communicate with their backend services, and this is likely to only get worse going forward”?

@AaronSterling, @rapropos - finally got it to working. :slight_smile:

Once again, @AaronSterling - if it wasn’t for you pointing out the import for “fromPromise” I wouldn’t have reached this point! Thanks again!

So it was indeed how I was reading the returned object, the one that I was converting from Promise to Observable in my base-class, in my home-service.ts.

Apparently, I still need to read the returned JSON as I would do if it were a Promise (i.e., like, res.result). So the following function in home-service.ts:

     getHomeData(): Observable<DataObj[]> {
        return super.invokeRestMethod(myURL, 'GET')
          .map((res:Response) => res.json())
          .catch((error:any) => Observable.throw(error.json().error || 'Server error'));
      }

should really be like:

     getHomeData(): Observable<DataObj[]> {
        return super.invokeRestMethod(myURL, 'GET')
          .map((res:any) => res.result)
          .catch((error:any) => Observable.throw((error.message) ? error.message :
        error.status ? `${error.status} - ${error.statusText}` : 'Server error'));
      }

Just wanted to share, we spent so much time on this! :slight_smile: