<private> new CustomCode()
This class provides a way to invoke custom API endpoints for the currently active mobile backend.
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, successCallback, errorCallback)
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.
-
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 Argument Description path
String The path of the endpoint following the platform prefix, i.e. {BaseUrl}/mobile/custom/{path to the custom API endpoint}. method
String HTTP method that is invoked. 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. successCallback
CustomCode~successCallback <optional>
Optional callback invoked on success that returns the status code and the data from the request (deprecated use promises instead). errorCallback
CustomCode~errorCallback <optional>
Optional callback invoked on failure that returns the status code and the data from the request (deprecated use promises instead). - Source:
Returns:
- Type
- Promise.<(NetworkResponse|NetworkResponse)>
Examples
path: "TasksAPI/tasks/100"
method: "GET,POST,PUT,DELETE"
data: { "name": "Complete reports", "completed": false, "priority": "high", "dueDate": "2015-03-15T17:00:00Z" } These methods must be defined in the custom API for these methods to work.
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) { } //output { "name": "Complete reports", "completed": false, "priority": "high", "dueDate": "2015-03-15T17:00:00Z" }
Type Definitions
-
errorCallback(statusCode, message)
Callback invoked on error.
-
Callback invoked on error.
Parameters:
Name Type Description statusCode
Number Any HTTP status code returned from the server, if available. message
String The HTTP payload from the server, if available, or an error message. - Deprecated:
-
- Use promises instead
- Source:
-
successCallback()
Callback invoked after successfully flushing analytics events.
-
Callback invoked after successfully flushing analytics events.
- Deprecated:
-
- Use promises instead
- Source: