Search.../

getPolicy( )

Retrieves a policy by ID.

Description

The getPolicy() function returns a Promise that resolves to a policy whose ID matches the given ID.

Syntax

function getPolicy(policyId: string): Promise<Policy>

getPolicy Parameters

NAME
TYPE
DESCRIPTION
policyId
string

Policy ID.

Returns

The requested policy.

Return Type:

Promise<
Policy
>
NAME
TYPE
DESCRIPTION
_createdDate
Date

Date and time when the policy was created.

_id
string

Policy ID.

_updatedDate
Date

Date and time of the policy's latest update in.

body
string

Policy body, usually containing various terms and conditions.

Min: 1 character

Max: 50000 characters.

Note: You can format text using various HTML tags such as <p>, <b>, <ul>, etc.

eventId
string

ID of the event to which the policy belongs.

name
string

Policy name that is visible in the dashboard and checkout form.

Min: 1 character

Max: 40 characters

revision
string

Revision number, which increments by 1 each time the policy is updated. The existing revision must be used when updating a policy to prevent conflicting changes. You'll get an error if you try to use the previous revision.

Was this helpful?

Get Policy

Copy Code
1import { policies } from 'wix-events.v2';
2
3// define policy ID
4const policyId = '6933ddf1-26c7-46c3-9924-e78c833d6cca';
5
6// get policy
7async function getPolicy() {
8 try {
9 const result = await policies.getPolicy(policyId);
10 return result;
11 }
12 catch (error) {
13 console.error(error);
14 // Handle the error
15 }
16 };
17
18/* Returns a promise that resolves to
19 the policy.
20{
21 "_id": "6933ddf1-26c7-46c3-9924-e78c833d6cca",
22 "revision": "1",
23 "_createdDate": "2023-03-07T13:18:09.185Z",
24 "_updatedDate": "2023-03-07T13:18:09.185Z",
25 "name": "Terms and Conditions Event 2",
26 "body": "<p>Nobody will be allowed admission to the Event without a valid ticket or pass.</p>",
27 "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
28}
29*/
Get Policy (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { policies } from 'wix-events.v2';
3
4// define policy ID
5const policyId = '6933ddf1-26c7-46c3-9924-e78c833d6cca';
6
7export const getPolicy = webMethod(Permissions.Anyone, async () => {
8 try {
9 const result = await policies.getPolicy(policyId);
10 return result;
11 }
12 catch (error) {
13 console.error(error);
14 // Handle the error
15 }
16 });
17
18/* Promise resolves to:
19 * {
20 * "_id": "6933ddf1-26c7-46c3-9924-e78c833d6cca",
21 * "revision": "1",
22 * "_createdDate": "2023-03-07T13:18:09.185Z",
23 * "_updatedDate": "2023-03-07T13:18:09.185Z",
24 * "name": "Terms and Conditions Event 2",
25 * "body": "<p>Nobody will be allowed admission to the Event without a valid ticket or pass.</p>",
26 * "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
27 * }
28 */
29