Using the JavaScript API
In this section, we will explore some useful client-side APIs of ABP Framework. Some of these APIs provide simple ways to use server-side defined features such as authentication and localization, while others provide solutions for common UI patterns, such as message boxes and notifications.
All the client-side JavaScript APIs are global objects and functions that are declared under the abp
namespace. Let's begin with accessing the current user's information in your JavaScript code.
Accessing the current user
We are using the ICurrentUser
service on the server side to get information about the currently logged-in user. In the JavaScript code, we can use the global abp.currentUser
object, as shown here:
var userId = abp.currentUser.id; var userName = abp.currentUser. userName;
By doing this, we can get the user's ID and username. The following JSON object is an example of the abp.currentUser
object:
{ isAuthenticated...