Assigns events to a single category.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function assignEvents(
categoryId: string,
eventId: Array<string>,
): Promise<void>;
ID of category to which events should be assigned.
A list of events IDs.
import { categories } from "wix-events.v2";
import { webMethod, Permissions } from "wix-web-module";
import { elevate } from "wix-auth";
const elevatedAssignEvents = elevate(categories.assignEvents);
/*
* Sample categoryId value: "6ec293a8-1b47-4337-9c4e-9a6aeb35e66a",
* Sample eventId value: ["4e5e4adb-9778-4171-a9bb-44e27834ac89"]
*/
export const myAssignEventsFunction = webMethod(
Permissions.Anyone,
async (categoryId, eventId) => {
try {
const assignedEvents = await elevatedAssignEvents(categoryId, eventId);
console.log("Events are assigned to the category.");
return assignedEvents;
} catch (error) {
console.error(error);
// Handle the error
}
},
);
/* Promise resolves to void */
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.