Method signature
Method is used for OK REST API method calls.
OKSDK.REST.call(methodName, methodParams, onResult)
Where:
- methodName - REST API method name. I.e., “users.getCurrentUser”;
- methodParam - method parameters as an object. I.e:
var methodParams = {
"fields": "user.id, user.name"
}
- onResult - callback function that is going to be called on OK API response.
Callback
Callback function must have a following signature:
function onResult(status, data, error)
Where:
- status - method invocation status. Possible values: “error”, “ok”;
- data - method invocation result, object. (more info on a corresponding API method’s page). Filled only if status is ok;
- error - method invocation error, object. Filled only if status is error. Contains following information:
- error_code - error code, number;
- error_msg - error message, string;
- error_data - additional error info, string.
Example usage
OKSDK.REST.call(
"users.getCurrentUser",
{"fields": "user.id, user.name"},
function (status, data, error) {
if (status == "ok") {
console.log("UID: " + data.uid);
}
if (status == "error") {
console.log("Error: " + JSON.stringify(error));
}
}
);