Deletes a category.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function deleteCategory(categoryId: string): Promise<void>;
ID of category to be deleted.
import { categories } from "wix-events.v2";
import { webMethod, Permissions } from "wix-web-module";
import { elevate } from "wix-auth";
const elevatedDeleteCategory = elevate(categories.deleteCategory);
// Sample categoryId value: "5fa9929d-6782-4927-9b8c-304ca9ca6e93"
export const myDeleteCategoryFunction = webMethod(
Permissions.Anyone,
async (categoryId) => {
try {
const deletedCategory = await elevatedDeleteCategory(categoryId);
console.log("Category is deleted");
return deletedCategory;
} 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.