Reputation: 1151
The following URL works - I've tested it in Chrome and Postman.
https://localhost:44319/api/portfolio
Here is my invocation in my typescript module. I have a breakpoint on this line and I see this line execute. (If you think a broader view of my code is relevant to the question, please let me know and I will post it.)
this.http.get<Portfolio[]>('https://localhost:44319/api/portfolio');
The line executes, but my web API method doesn't get called. I know it's not getting called because I am running my project in debug mode and I have breakpoints in my typescript method and in the first line of my web API method. I see the breakpoint being hit within the typescript executing on the client side, but the breakpoint within my server side web API method doesn't get hit.
(Although, as I mentioned, if I execute that exact URL from Chrome or Postman the server-side breakpoint hits.)
What am I doing wrong? Thanks!
Upvotes: 1
Views: 602
Reputation: 2817
You should do:
this.http.get<Portfolio[]>('https://localhost:44319/api/portfolio').subscribe(v
=> { this.Portfolios = r; });
or
this.Portfolios = await this.http.get<Portfolio[]>('https://localhost:44319/api/portfolio').toPromise();
Upvotes: 3