getLabel( )


Retrieves a label.

The getLabel() function returns a Promise that resolves when the specified label is retrieved.

Note: Only visitors with Manage Contacts permissions can retrieve labels. You can override the permissions by setting the suppressAuth option to true.

Method Declaration
Copy
function getLabel(key: string, options: AuthOptions): Promise<Label>;
Method Parameters
keystringRequired

Label key.

key is generated when the label is created and cannot be modified, even if displayName changes.


optionsAuthOptions

Authorization options.

Returns
Return Type:Promise<Label>
Get a label
JavaScript
import { Permissions, webMethod } from "wix-web-module"; import { contacts } from "wix-crm-backend"; export const myGetLabelFunction = webMethod(Permissions.Anyone, () => { const labelKey = "custom.active-customer"; const options = { suppressAuth: false, }; return contacts .getLabel(labelKey, options) .then((label) => { return label; }) .catch((error) => { console.error(error); }); }); /* * Promise resolves to: * * { * "_createdDate": "2021-01-20T00:31:41Z", * "_updatedDate": "2021-01-20T00:31:41Z" * "namespace": "custom", * "key": "custom.active-customer", * "displayName": "Active Customer", * "labelType": "USER_DEFINED" * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?