JavaScript adapters can use the IBM MobileFirst™ Platform Server JavaScript API to perform server-related operations such as: calling other adapters, logging adapter activity, getting values of configuration properties, reporting activities to IBM MobileFirst Analytics, and getting the identity of the request issuer.
The JavaScript server-side API is provided in two classes:
Examples of the use of the API are provided in the following sections.
AuthenticatedUser user =
securityContext.getAuthenticatedUser();
return "Hello " + user.getDisplayName();
}
The following example shows how to use this function to call a JavaScript adapter:
function callAnotherProcedure() {
var invocationData = {
adapter : “JsAdapter”, procedure :
“getStories”
};
return MFP.Server.invokeProcedure();}
For more information,
see Configuring adapters.For example, assume you have a user-defined property, databaseName. To get its value, you could write the following code:
var dbName = MFP.Server.getPropertyValue(‘databaseName’);
For
more information, see Configuring adapters.For example, to send the string Getting account balance, you might write:
function getBalance(user) {
MFP.Server.logActivity(‘Getting account balance);
// perform operation
}