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
Policy ID.
Returns
The requested policy.
Return Type:
NAME
TYPE
DESCRIPTION
Date and time when the policy was created.
Policy ID.
Date and time of the policy's latest update in.
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.
ID of the event to which the policy belongs.
Policy name that is visible in the dashboard and checkout form.
Min: 1 character
Max: 40 characters
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?
1import { policies } from 'wix-events.v2';23// define policy ID4const policyId = '6933ddf1-26c7-46c3-9924-e78c833d6cca';56// get policy7async 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 error15 }16 };1718/* Returns a promise that resolves to19 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*/
1import { Permissions, webMethod } from 'wix-web-module';2import { policies } from 'wix-events.v2';34// define policy ID5const policyId = '6933ddf1-26c7-46c3-9924-e78c833d6cca';67export 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 error15 }16 });1718/* 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