Class SxcWebApi
helper API to run ajax / REST calls to the server it will ensure that the headers etc. are set correctly and that urls are rewritten
sxc.webApi
Helpers on the Sxc Controller
The WebApi object on the App/Module-specific sxc
-controller is for AJAX calls. It helps you in these advanced cases:
- to read/write content-items using REST
- to access your apps WebApi controllers
How to use
First you must ensure that you have the $2sxc
manager on your page, which will get you a module-specific sxc
controller. Read about the $2sxc global here.
Here's a simple example (assuming you have the $2sxc manager):
<a onclick="$2sxc(this).webApi.fetchJson('app/auto/data/Category').then(handleResult);">
get all Categories
</a>
The APIs to Get Data
How to Get the Current Context's sxc
Controller
Before you continue, make sure you know how to resolve/get your sxc
-controller, as it is unique for each Dnn-Module. This is because each action needs to know which module it belongs to. Read about the 3 ways to get this in the $2sxc Manager docs. Here you'll also find out more about the sxc-controller.
Package: Api.Js.SxcJs
Methods
delete(string | ZzzAjaxSettingsDeprecated, any, any, boolean)
Deprecated - docs in the separate interface
sxc.webApi
Helpers on the Sxc Controller
The WebApi object on the App/Module-specific sxc
-controller is for AJAX calls. It helps you in these advanced cases:
- to read/write content-items using REST
- to access your apps WebApi controllers
How to use
First you must ensure that you have the $2sxc
manager on your page, which will get you a module-specific sxc
controller. Read about the $2sxc global here.
Here's a simple example (assuming you have the $2sxc manager):
<a onclick="$2sxc(this).webApi.fetchJson('app/auto/data/Category').then(handleResult);">
get all Categories
</a>
The APIs to Get Data
How to Get the Current Context's sxc
Controller
Before you continue, make sure you know how to resolve/get your sxc
-controller, as it is unique for each Dnn-Module. This is because each action needs to know which module it belongs to. Read about the 3 ways to get this in the $2sxc Manager docs. Here you'll also find out more about the sxc-controller.
Declaration
function delete(settingsOrUrl: string | ZzzAjaxSettingsDeprecated, params?: any, data?: any, preventAutoFail?: boolean)
Parameters
Type | Name | Description |
---|---|---|
string | ZzzAjaxSettingsDeprecated | settingsOrUrl | |
any | params | |
any | data | |
boolean | preventAutoFail |
Returns
Type | Description |
---|---|
any |
fetchJson(string, string | Record<string, any>, string)
Will retrieve data from the backend using a standard fetch and give you an object.
sxc.webApi
Helpers on the Sxc Controller
The WebApi object on the App/Module-specific sxc
-controller is for AJAX calls. It helps you in these advanced cases:
- to read/write content-items using REST
- to access your apps WebApi controllers
How to use
First you must ensure that you have the $2sxc
manager on your page, which will get you a module-specific sxc
controller. Read about the $2sxc global here.
Here's a simple example (assuming you have the $2sxc manager):
<a onclick="$2sxc(this).webApi.fetchJson('app/auto/data/Category').then(handleResult);">
get all Categories
</a>
The APIs to Get Data
How to Get the Current Context's sxc
Controller
Before you continue, make sure you know how to resolve/get your sxc
-controller, as it is unique for each Dnn-Module. This is because each action needs to know which module it belongs to. Read about the 3 ways to get this in the $2sxc Manager docs. Here you'll also find out more about the sxc-controller.
Declaration
function fetchJson<T>(url: string, data?: string | Record<string, any>, method?: string)
Parameters
Type | Name | Description |
---|---|---|
string | url |
a full url or short-hand like |
string | Record<string, any> | data |
optional POST data |
string | method |
optional method, defaults to |
Returns
Type | Description |
---|---|
Promise<T> | a Promise containing any object. |
fetchRaw(string, string | Record<string, any>, string)
Will retrieve data from the backend using a standard fetch.
sxc.webApi
Helpers on the Sxc Controller
The WebApi object on the App/Module-specific sxc
-controller is for AJAX calls. It helps you in these advanced cases:
- to read/write content-items using REST
- to access your apps WebApi controllers
How to use
First you must ensure that you have the $2sxc
manager on your page, which will get you a module-specific sxc
controller. Read about the $2sxc global here.
Here's a simple example (assuming you have the $2sxc manager):
<a onclick="$2sxc(this).webApi.fetchJson('app/auto/data/Category').then(handleResult);">
get all Categories
</a>
The APIs to Get Data
How to Get the Current Context's sxc
Controller
Before you continue, make sure you know how to resolve/get your sxc
-controller, as it is unique for each Dnn-Module. This is because each action needs to know which module it belongs to. Read about the 3 ways to get this in the $2sxc Manager docs. Here you'll also find out more about the sxc-controller.
Declaration
function fetchRaw(url: string, data?: string | Record<string, any>, method?: string)
Parameters
Type | Name | Description |
---|---|---|
string | url |
a full url or short-hand like |
string | Record<string, any> | data |
optional POST data |
string | method |
optional method, defaults to |
Returns
Type | Description |
---|---|
Promise<Response> | a Promise containing a Response object, just like a normal fetch would. example: webApi.fetchRaw('Rss/Feed'); example: webApi.fetchRaw(webApi.url('Rss/Feed', { id: 47 })); // url params example: webApi.fetchRaw('Rss/Feed', { id: 47 }); // post params example: webApi.fetchRaw(webApi.url('Rss/Feed', { id: 47 }), { something: 'this is a test' }); // url & post params maybe: webApi.fetchRaw({url: 'Rss/Feed', params: { id: 47 }}) maybe: webApi.fetchRaw({url: ..., params: { ...}, body: { ...}, method: 'GET' }) |
get(string | ZzzAjaxSettingsDeprecated, any, any, boolean)
Deprecated - docs in the separate interface
sxc.webApi
Helpers on the Sxc Controller
The WebApi object on the App/Module-specific sxc
-controller is for AJAX calls. It helps you in these advanced cases:
- to read/write content-items using REST
- to access your apps WebApi controllers
How to use
First you must ensure that you have the $2sxc
manager on your page, which will get you a module-specific sxc
controller. Read about the $2sxc global here.
Here's a simple example (assuming you have the $2sxc manager):
<a onclick="$2sxc(this).webApi.fetchJson('app/auto/data/Category').then(handleResult);">
get all Categories
</a>
The APIs to Get Data
How to Get the Current Context's sxc
Controller
Before you continue, make sure you know how to resolve/get your sxc
-controller, as it is unique for each Dnn-Module. This is because each action needs to know which module it belongs to. Read about the 3 ways to get this in the $2sxc Manager docs. Here you'll also find out more about the sxc-controller.
Declaration
function get(settingsOrUrl: string | ZzzAjaxSettingsDeprecated, params?: any, data?: any, preventAutoFail?: boolean)
Parameters
Type | Name | Description |
---|---|---|
string | ZzzAjaxSettingsDeprecated | settingsOrUrl | |
any | params | |
any | data | |
boolean | preventAutoFail |
Returns
Type | Description |
---|---|
any |
headers(string)
All the headers which are needed in an ajax call for this to work reliably. Use this if you need to get a list of headers in another system
sxc.webApi
Helpers on the Sxc Controller
The WebApi object on the App/Module-specific sxc
-controller is for AJAX calls. It helps you in these advanced cases:
- to read/write content-items using REST
- to access your apps WebApi controllers
How to use
First you must ensure that you have the $2sxc
manager on your page, which will get you a module-specific sxc
controller. Read about the $2sxc global here.
Here's a simple example (assuming you have the $2sxc manager):
<a onclick="$2sxc(this).webApi.fetchJson('app/auto/data/Category').then(handleResult);">
get all Categories
</a>
The APIs to Get Data
How to Get the Current Context's sxc
Controller
Before you continue, make sure you know how to resolve/get your sxc
-controller, as it is unique for each Dnn-Module. This is because each action needs to know which module it belongs to. Read about the 3 ways to get this in the $2sxc Manager docs. Here you'll also find out more about the sxc-controller.
Declaration
function headers(method?: string)
Parameters
Type | Name | Description |
---|---|---|
string | method |
Returns
Type | Description |
---|---|
Record<string, string> |
post(string | ZzzAjaxSettingsDeprecated, any, any, boolean)
Deprecated - docs in the separate interface
sxc.webApi
Helpers on the Sxc Controller
The WebApi object on the App/Module-specific sxc
-controller is for AJAX calls. It helps you in these advanced cases:
- to read/write content-items using REST
- to access your apps WebApi controllers
How to use
First you must ensure that you have the $2sxc
manager on your page, which will get you a module-specific sxc
controller. Read about the $2sxc global here.
Here's a simple example (assuming you have the $2sxc manager):
<a onclick="$2sxc(this).webApi.fetchJson('app/auto/data/Category').then(handleResult);">
get all Categories
</a>
The APIs to Get Data
How to Get the Current Context's sxc
Controller
Before you continue, make sure you know how to resolve/get your sxc
-controller, as it is unique for each Dnn-Module. This is because each action needs to know which module it belongs to. Read about the 3 ways to get this in the $2sxc Manager docs. Here you'll also find out more about the sxc-controller.
Declaration
function post(settingsOrUrl: string | ZzzAjaxSettingsDeprecated, params?: any, data?: any, preventAutoFail?: boolean)
Parameters
Type | Name | Description |
---|---|---|
string | ZzzAjaxSettingsDeprecated | settingsOrUrl | |
any | params | |
any | data | |
boolean | preventAutoFail |
Returns
Type | Description |
---|---|
any |
put(string | ZzzAjaxSettingsDeprecated, any, any, boolean)
Deprecated - docs in the separate interface
sxc.webApi
Helpers on the Sxc Controller
The WebApi object on the App/Module-specific sxc
-controller is for AJAX calls. It helps you in these advanced cases:
- to read/write content-items using REST
- to access your apps WebApi controllers
How to use
First you must ensure that you have the $2sxc
manager on your page, which will get you a module-specific sxc
controller. Read about the $2sxc global here.
Here's a simple example (assuming you have the $2sxc manager):
<a onclick="$2sxc(this).webApi.fetchJson('app/auto/data/Category').then(handleResult);">
get all Categories
</a>
The APIs to Get Data
How to Get the Current Context's sxc
Controller
Before you continue, make sure you know how to resolve/get your sxc
-controller, as it is unique for each Dnn-Module. This is because each action needs to know which module it belongs to. Read about the 3 ways to get this in the $2sxc Manager docs. Here you'll also find out more about the sxc-controller.
Declaration
function put(settingsOrUrl: string | ZzzAjaxSettingsDeprecated, params?: any, data?: any, preventAutoFail?: boolean)
Parameters
Type | Name | Description |
---|---|---|
string | ZzzAjaxSettingsDeprecated | settingsOrUrl | |
any | params | |
any | data | |
boolean | preventAutoFail |
Returns
Type | Description |
---|---|
any |
request(string | ZzzAjaxSettingsDeprecated, any, any, boolean, string)
Deprecated - docs in the separate interface
sxc.webApi
Helpers on the Sxc Controller
The WebApi object on the App/Module-specific sxc
-controller is for AJAX calls. It helps you in these advanced cases:
- to read/write content-items using REST
- to access your apps WebApi controllers
How to use
First you must ensure that you have the $2sxc
manager on your page, which will get you a module-specific sxc
controller. Read about the $2sxc global here.
Here's a simple example (assuming you have the $2sxc manager):
<a onclick="$2sxc(this).webApi.fetchJson('app/auto/data/Category').then(handleResult);">
get all Categories
</a>
The APIs to Get Data
How to Get the Current Context's sxc
Controller
Before you continue, make sure you know how to resolve/get your sxc
-controller, as it is unique for each Dnn-Module. This is because each action needs to know which module it belongs to. Read about the 3 ways to get this in the $2sxc Manager docs. Here you'll also find out more about the sxc-controller.
Declaration
function request(settings: string | ZzzAjaxSettingsDeprecated, params: any, data: any, preventAutoFail: boolean, method: string)
Parameters
Type | Name | Description |
---|---|---|
string | ZzzAjaxSettingsDeprecated | settings | |
any | params | |
any | data | |
boolean | preventAutoFail | |
string | method |
Returns
Type | Description |
---|---|
any |
url(string, string | Record<string, any>)
helper API to run ajax / REST calls to the server it will ensure that the headers etc. are set correctly and that urls are rewritten
sxc.webApi
Helpers on the Sxc Controller
The WebApi object on the App/Module-specific sxc
-controller is for AJAX calls. It helps you in these advanced cases:
- to read/write content-items using REST
- to access your apps WebApi controllers
How to use
First you must ensure that you have the $2sxc
manager on your page, which will get you a module-specific sxc
controller. Read about the $2sxc global here.
Here's a simple example (assuming you have the $2sxc manager):
<a onclick="$2sxc(this).webApi.fetchJson('app/auto/data/Category').then(handleResult);">
get all Categories
</a>
The APIs to Get Data
How to Get the Current Context's sxc
Controller
Before you continue, make sure you know how to resolve/get your sxc
-controller, as it is unique for each Dnn-Module. This is because each action needs to know which module it belongs to. Read about the 3 ways to get this in the $2sxc Manager docs. Here you'll also find out more about the sxc-controller.
Declaration
function url(url: string, params?: string | Record<string, any>)
Parameters
Type | Name | Description |
---|---|---|
string | url |
A short, medium or long url.
Short like |
string | Record<string, any> | params |
Optional parameters as string or object, will be added to url-params. |
Returns
Type | Description |
---|---|
string | In the cases of a short/medium url, it will auto-expand to have the full url as needed for an API call. |