From the course: Advanced Web APIs with ASP.NET Core in .NET 6
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Consuming the API with JavaScript - C# Tutorial
From the course: Advanced Web APIs with ASP.NET Core in .NET 6
Consuming the API with JavaScript
[Narrator] When consuming our API from JavaScript there are certain security aspects that we need to keep in mind. Let me show you. First of all, I'm adding a new project to our solution and this time I'm using an ASP.NetCore web app. So basically, razor pages. I'll call it HPlusSport.Web and leave the remaining settings as is. And then on the one page that is created index CSHML, I'll ignore error in privacy. I will add some output. And the output will be the list of products that the API returns. So I'll start by adding an unordered list. Let's call it maybe products list and I'll fill that with JavaScript. So the template defines a script section which will be rendered towards the end of the page. And in that section, I'll put my script tag and my code that will call the URL. Well, the URL is of course, the URL of the existing API. So let's double check with the settings we have here. So the base URL is local…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Introduction31s
-
(Locked)
Enforcing HTTPS5m 16s
-
(Locked)
Consuming the API with JavaScript4m 44s
-
(Locked)
Cross-origin resource sharing (CORS)4m 12s
-
(Locked)
Enabling CORS4m 44s
-
(Locked)
Adding ASP.NET Core Identity6m 56s
-
(Locked)
Adding token-based authentication8m 51s
-
(Locked)
OAuth and OpenID Connect4m 19s
-
(Locked)
Securing the API with IdentityServer6m 10s
-
(Locked)
Consuming the protected API6m 40s
-
(Locked)
-