Невозможно получить результат от действия веб-API, вызванного из углового - PullRequest
0 голосов
/ 08 февраля 2019

Я пытаюсь получить детали UserProfile, передавая электронную почту пользователя в Angular по запросу POST в WebApi, но я не могу получить данные.Я получаю эту ошибку: неожиданный конец ввода.

Вот метод, который делает вызов:

getUserProfile(resourceEmail: string): Observable<any> {
debugger
return this.http.post<UserVM>(this.getAPI('FetchUserProfile')+'/? emailId='+resourceEmail,
  this.httpOptions).pipe(
    map(data => data),
    catchError(this.handleError<any>())
  );
 }

код действия контроллера

    [System.Web.Mvc.HttpPost]
    [System.Web.Mvc.Route("ApiWithAction")]
    public HttpResponseMessage FetchUserProfile(string emailId)
    {
        try
        {
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, _userProfileService.GetUserProfile(emailId));
            return response;
        }
        catch (Exception ex)
        {
            //client.TrackException(ex.InnerException);
            return null; //need to check and confirm what needs return to UI               
        }
    }

код подписки

 getBookingList() {
this.bookingListSubscription = this.restService.getCompletedListForGrid(this.booking).subscribe(
  data => {

    this.bookingList = data;

    this.bookingList.forEach((element) => {
      element.StartDate = new Date(element.StartDate),
        element.EndDate = new Date(element.EndDate);
    });
    this.gridData = this.bookingList;
    this.spinner.hide();
  });

Error

1 Ответ

0 голосов
/ 08 февраля 2019

Возможно, вы присваиваете значение неправильно, лучше назначить значение, например -

this.restService.getUserProfile("")
 .subscribe(data => {
    this.bookingListSubscription
    .... other code
 });
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...