CustomCode
This class provides a way to invoke custom API endpoints for the
currently active mobile backend. Callers should use
MobileBackend's customCode property.
- Source:
Methods
invokeCustomCodeJSONRequest(path, method, data) → {Promise.<NetworkResponse>}
Invoke custom code JSON request.
Allows the user to call custom Code defined on the UI and assigned to the backend defined by the user
This custom endpoint should return data only in JSON format.
Parameters:
Name | Type | Description |
---|---|---|
path |
String | The path of the endpoint without platform prefix. |
method |
String | HTTP method that is invoked, this method accepts: GET, POST, PUT, DELETE, PATCH. |
data |
Object | Data that is inserted into the call on the server for POST and PUT methods. Only accepts a JSON object and/or JavaScript array. |
- Source:
Returns:
- Type
- Promise.<NetworkResponse>
Example
mcs.mobileBackend.customCode
.invokeCustomCodeJSONRequest('TaskApi1/tasks/100', 'GET', null)
.then(invokeSuccess, invokeError);
function invokeSuccess(response) {
console.log(response.data);// returns object in JSON format
}
function invokeError(response) {
console.error(response);
}