> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt ## Resource: Call Backend Code from a jsw Web Module ## Article: Call Backend Code from a jsw Web Module ## Article Link: https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/web-modules/call-backend-code-from-a-jsw-web-module.md ## Article Content: # Deprecated: Call Backend Code from the Frontend Using a jsw Web Module [Web modules](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/web-modules/about-web-modules.md) 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](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/web-modules/call-backend-code-from-the-frontend.md) 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. ```js export myFunction(someParam) { // Some functionality to call from the frontend return `You passed me ${someParam}`; } ``` ## Step 2 | Set permissions Set [permissions](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/web-modules/about-web-modules.md#permissions) for each function in the web module if necessary. The default permission is **Anyone**. You can set permissions in the Wix Editor or by editing the permissions.json file, depending on your development environment: ::::tabs :::Wix-Editor 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. 1. Click the dropdown next to a function name to define its permissions. ::: :::Wix-and-Local-IDE When using the Wix IDE or a local IDE with GitHub integration, you can add and edit permissions using the `permissions.json` file. The `permissions.json` file is located in the `src/backend` folder. The file contains a `"web-methods"` object where each key represents a web module file using the syntax `backend/{path-to-file}/.jsw`. Under each file key, you define permission objects for each exported function. The `"web-methods"` object must also contain a `"*"` key that defines default permissions for any functions not explicitly configured. Set permissions using the following values: * **Owner-only access**: * `siteOwner.invoke`: `true` * `siteMember.invoke`: `false` * `anonymous.invoke` : `false` * **Site member access**: * `siteOwner.invoke`: `true` * `siteMember.invoke`: `true` * `anonymous.invoke` : `false` * **Anyone can access**: * `siteOwner.invoke`: `true` * `siteMember.invoke` : `true` * `anonymous.invoke`: `true` Here is an example with 3 functions from `helperFunctions.jsw`, each having different permission levels: ```json // permissions.json file { "web-methods": { // Default web method. "*": { "*": { "siteOwner": { "invoke": true }, "siteMember": { "invoke": true }, "anonymous": { "invoke": true } } }, // Web method for the web module. "backend/helperFunctions.jsw": { "calculate": { "siteOwner": { "invoke": true }, "siteMember": { "invoke": true }, "anonymous": { "invoke": true } }, "fetchData": { "siteOwner": { "invoke": true }, "siteMember": { "invoke": false }, "anonymous": { "invoke": false } }, "syncWithServer": { "siteOwner": { "invoke": true }, "siteMember": { "invoke": true }, "anonymous": { "invoke": false } } } } } ``` ::: :::: ## 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: ```javascript import { myFunction } from 'backend/weather.web'; ``` 2. Call the imported function: ```js const fromBackend = await myFunction(someValue); ``` Remember, web module functions are always asynchronous.