Where are you subscribing to the observable?

On Fri, Feb 16, 2018, 17:48 James Niesen <jamesnie...@gmail.com> wrote:

> Hi
> I'm learning the latest and greatest Angular using type script.  I have an
> ajax request that works fine in jQuery.  I'm trying to convert this to a
> post request.  Below are the two calls.  Does anyone see anything that I'm
> doing wrong in the typescript or can help point me in the right direction?
>
> Thanks
>
> 1.  Working JQuery:
>
>     var url = "http://bsdevtest2/_layouts/15/GHC.WellnessClasses/ajax.ashx
> ";
>
>     $.ajax({
>
>         url: url,
>
>         data: {
>
>             Function: "GetClassOfferings",
>
>             Host: "http://bsdevtest2";
>
>         },
>
>         type: 'POST',
>
>         success: function (json) {
>
>             alert(json.Offerings.Host);
>
>         },
>
>         error: function (xhr, err) {
>
>
>         },
>
>         complete: function () {
>
>
>
>         }
>
>     });
>
>
> 2. Attempt at Angular Service http post
>
>   getClassOfferings (): Observable <any> {
>    //var host = location.protocol + "://" + location.host;
>    var host = "http://bsdevtest2";;
>    var parameter = JSON.stringify({Function:"GetClassOfferings", Host:host
> });
>    return this.http.post(AJAX_URL, parameter)
>    .pipe(
>      tap(Offerings => this.log(`fetched class offerings`)),
>      catchError(this.handleError('getClassOfferings', []))
>    );
>  }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Angular and AngularJS discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to angular+unsubscr...@googlegroups.com.
> To post to this group, send email to angular@googlegroups.com.
> Visit this group at https://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>
-- 
Lucas Lacroix
Computer Scientist
Advanced Technology Division, MEDITECH <http://ehr.meditech.com/>
781-774-2293

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to