webMethod( )

Defines a backend function that can be called from the frontend.

The webMethod() function is a wrapper used to export functions from backend code that can be called from the frontend.

The permissions parameter is used to define the permissions needed to call the function in frontend code. Import the Permissions enum from the wix-web-module module to define the permissions. The permission options are:

  • Permissions.Anyone: Any site visitor can call the function.
  • Permissions.Admin: Only site admins can call the function.
  • Permissions.SiteMember: Only site members can call the function.

Web methods must be defined in files with a .web.js extension.

Method Declaration
Copy
Method Parameters
permissionsPermissionsRequired

Permissions needed to call the function in frontend code.


_functionFunctionRequired

Function to export.

Returns
Return Type:Promise<Function>
Was this helpful?
Yes
No