bulkCreateCategory( )


Creates multipe categories at once.

Authentication
  • When developing websites or building an app with Blocks, this method may require elevated permissions, depending on the identity of the user calling it and the calling user’s permissions.
  • When building apps without Blocks or for headless projects, you can only call this method directly when authenticated as a Wix app or Wix user identity. When authenticated as a different identity, you can call this method using elevation.
  • Elevation permits users to call methods they typically cannot access. Therefore, you should only use it intentionally and securely.
Permissions
Manage Events - all permissions
Manage Events
Learn more about app permissions.
Method Declaration
Copy
function bulkCreateCategory(
  categories: Array<Category>,
): Promise<BulkCreateCategoryResponse>;
Method Parameters
categoriesArray<Category>Required

Categories to create.

Returns
Return Type:Promise<BulkCreateCategoryResponse>
JavaScript
import { categories } from "@wix/events"; /* * Sample categories value: * [ * { * "name": "leather", * "states": ["MANUAL"] * }, * { * "name": "shoes", * "states": ["MANUAL"] * } * ] */ export async function myBulkCreateCategoryFunction(categories) { try { const createdCategories = await categories.bulkCreateCategory(categories); console.log("Created categories: ", createdCategories); return createdCategories; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * "results": [ * { * "itemMetadata": { * "originalIndex": 0, * "success": true, * "_id": "7d2560a8-b0ab-41fe-9c7c-6584157b2de1" * }, * "item": { * "name": "leather", * "states": [ * "MANUAL" * ], * "_id": "7d2560a8-b0ab-41fe-9c7c-6584157b2de1", * "_createdDate": "2024-04-23T07:27:41.048Z" * } * }, * { * "itemMetadata": { * "originalIndex": 1, * "success": true, * "_id": "022cdce2-6d8d-4dfd-9210-4b6671539173" * }, * "item": { * "name": "shoes", * "states": [ * "HIDDEN" * ], * "_id": "022cdce2-6d8d-4dfd-9210-4b6671539173", * "_createdDate": "2024-04-23T07:27:41.048Z" * } * } * ], * "bulkActionMetadata": { * "totalSuccesses": 2, * "totalFailures": 0, * "undetailedFailures": 0 * } * } */
Errors

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

Did this help?