Deletes an existing secret by ID.
The deleteSecret()
function returns a Promise that resolves when a secret from the Secrets Manager is deleted.
You can retrieve the id
parameter using the listSecretInfo()
function.
Note that the ID used here is the ID retrieved from listSecretInfo()
, not the secret name used by getSecret()
.
Note: Deleting a secret is irreversible and will break all code using the secret.
function deleteSecret(id: string): Promise<void>;
The ID of the secret to be deleted.
import { Permissions, webMethod } from "wix-web-module";
import wixSecretsBackend from "wix-secrets-backend";
export const deleteMySecret = webMethod(Permissions.Anyone, () => {
const id = "b741766c-eead-46fe-8e7f-fd01ff3d6e21";
return wixSecretsBackend
.deleteSecret(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.