Deprecated: Call Backend Code from the Frontend Using a jsw Web Module

Web modules allow you to write backend functions that you can easily call from the frontend.

Warning: Web modules defined using .jsw files are deprecated and you will soon be unable to create new .jsw files. However, existing .jsw web modules will continue work as expected. Switch to web module defined using .web.js files for your current and future projects.

The following describes how to create, export, and call web module functions.

Step 1 | Define a function in the backend

Add an exported function to an existing .jsw file.

Copy

Step 2 | Set permissions

Set permissions for each function in the web module if necessary. Permissions can only be added and updated in the editor's UI. The default permission is Anyone.

To set permissions for a web module function:

  1. Hover over your web module, click the more actions menu, and select Edit Web Module Permissions.
    The web module permissions panel opens and displays each exported function in your web module.

  2. Click the dropdown next to a function name to define its permissions.

Step 3 | Call the function in the frontend

To call a web method from the frontend:

  1. Import the exported web method from the web module you created above:

    Copy
  2. Call the imported function:

    Copy

    Remember, web module functions are always asynchronous.

Was this helpful?
Yes
No