Search.../

deleteBadge( )

Deletes a badge.

Description

The deleteBadge() function returns a Promise that resolves when the specified badge is deleted.

The badgeId parameter must be an ID from your site's Members/Badges collection. Typically, you retrieve the ID from the collection using a query or through a dataset.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function deleteBadge(_id: string): Promise<void>

deleteBadge Parameters

NAME
TYPE
DESCRIPTION
_id
string

Badge ID.

Returns

Return Type:

Promise<
void
>

Was this helpful?

Delete existing badge.

Copy Code
1import { badges } from 'wix-members.v2';
2import { elevate } from 'wix-auth';
3
4/* Sample _id value: '50dca3d3-f142-44ca-87e9-d9302e1d4dd5' */
5
6export async function myDeleteBadgeFunction(_id) {
7 try {
8 const elevatedDeleteBadge = elevate(badges.deleteBadge);
9 const deletedBadge = await elevatedDeleteBadge(_id);
10
11 console.log("Badge deleted: ", deletedBadge);
12 return deletedBadge;
13 } catch (error) {
14 console.error(error);
15 // Handle the error
16
17 }
18
19}
20
21/* Promise resolves to void */