dimanche 6 octobre 2019

Angular App running with ASP NET Web Api 2.2 on IIS

I've encountered issue on my way to deploy Web Api 2.2 app on local IIS. The api has built in (inside wwwroot) compiled Angular app, and runs on my local IP, and that's how I want it to be. The problem is that when I try to get some data, for example angular tries to fill table using data fetched from API, I get such errors

Angular Json error

This is how my service looks like, I belive this is the place where the error might be, so I am posting the code

export class SubscriptionService {

  url = 'http://192.168.0.103:80/api/subscriptions/';

  constructor(private http: HttpClient) { }

  getSubscriptions(): Observable<Subscription[]> {
    return this.http.get<Subscription[]>(this.url);
  }
  GetSubscriptionById(Id: number): Observable<Subscription> {
    return this.http.get<Subscription>(this.url + Id);
  } 
  createSubscription(subscription: Subscription): Observable<Subscription> {
    const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };
    return this.http.post<Subscription>(this.url ,
      subscription, httpOptions);
  }

  deleteSubscription(Id: number): Observable<number> {
    const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };
    return this.http.delete<number>(this.url + Id,
      httpOptions);
  }



}

Do you have any experience with similar problems? I have more services within my Angular project, which looks basically the same, and with all of them I get the same error.




Aucun commentaire:

Enregistrer un commentaire