Consuming HTTP APIs
You can use any tool or technique to consume HTTP APIs from your JavaScript code. However, ABP provides the following ways as fully integrated solutions:
- You can use the
abp.ajax
API as an extension of thejQuery.ajax
API. - You can use dynamic JavaScript client proxies to call server-side APIs, just like you can with JavaScript functions.
- You can generate static JavaScript client proxies at development time.
Let's begin with the first one – the abp.ajax
API.
Using the abp.ajax API
The abp.ajax
API is a wrapper around the standard jQuery.ajax
API. It automatically handles all errors and shows a localized message to the user on an error case. It also adds the anti-forgery token to the HTTP header to satisfy Cross-Site Request Forgery (CSRF) protection on the server side.
The following example uses the abp.ajax
API to get a list of users from the server:
abp.ajax({ type: 'GET', url: &apos...