Deletes an existing secret by ID.
The deleteSecret()
function returns a Promise that resolves when the secret is deleted. You can retrieve the secret _id
using the listSecretInfo()
function.
Note: Deleting a secret is irreversible and will break all code using the secret.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function deleteSecret(_id: string): Promise<void>;
The unique ID of the secret to be deleted.
import { secrets } from "wix-secrets-backend.v2";
import { elevate } from "wix-auth";
export function deleteMySecret() {
const id = "b741766c-eead-46fe-8e7f-fd01ff3d6e21";
const elevatedDeleteSecret = elevate(secrets.deleteSecret);
return elevatedDeleteSecret(id)
.then(() => {
console.log("Secret deleted");
})
.catch((error) => {
console.error(error);
});
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.