Skip to main content

Functions module for invoking custom backend functions. This module allows you to invoke the custom backend functions defined in the app. This module is available to use with a client in all authentication modes:
  • Anonymous or User authentication (base44.functions): Functions are invoked with the current user’s permissions. Anonymous users invoke functions without authentication, while authenticated users invoke functions with their authentication context.
  • Service role authentication (base44.asServiceRole.functions): Functions are invoked with elevated admin-level permissions. The function code receives a request with admin authentication context.

Methods

invoke()

invoke(functionName, data): Promise<any>
Invokes a custom backend function by name. Calls a custom backend function deployed to the app. The function receives the provided data as named parameters and returns the result. If any parameter is a File object, the request will automatically be sent as multipart/form-data. Otherwise, it will be sent as JSON.

Parameters

functionName
string
required
The name of the function to invoke.
data
Record<string, any>
required
An object containing named parameters for the function.

Returns

Promise<any> Promise resolving to the function’s response. The data property contains the data returned by the function, if there is any.

Examples

const result = await base44.functions.invoke('calculateTotal', {
  items: ['item1', 'item2'],
  discount: 0.1
});
console.log(result.data.total);