Search.../

listSecretInfo( )

Developer Preview

Retrieves a list of objects containing information about all secrets.

Description

The listSecretInfo() function returns a Promise that resolves to a list containing information about all secrets stored on your site.

Note:

  • The secret's value does not get returned for security reasons. To retrieve a secret's value, use the getSecretValue() function.
Admin Method

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

Syntax

function listSecretInfo(): Promise<ListSecretInfoResponse>

listSecretInfo Parameters

This function does not take any parameters.

Returns

Fulfilled - A list of objects containing information about your site's secrets. Rejected - Error message.

Return Type:

Promise<
ListSecretInfoResponse
>
NAME
TYPE
DESCRIPTION
secrets
Array<
Secret
>

Object containing information for each secret.

Was this helpful?

Get information about your secrets

Copy Code
1import { secrets } from 'wix-secrets-backend.v2';
2
3export function getSecretInfo() {
4 return secrets.listSecretInfo()
5 .then((secrets) => {
6 return secrets;
7 })
8 .catch((error) => {
9 console.error(error);
10 });
11}
12
13/* Returns a Promise that resolves to:
14 * {
15 * "secrets": [
16 * {
17 * "id": "2eebccce-6c01-469d-a278-433fd96ba111",
18 * "createdDate": "2020-05-26T06:16:46.000Z",
19 * "updatedDate": "2020-05-28T12:21:10.000Z",
20 * "name": "MyFirstSecret",
21 * "description": "This is my first secret"
22 * },
23 * {
24 * "id": "ef4b43d4-851d-4b52-a07f-9a500a888371",
25 * "createdDate": "2020-06-02T08:23:54.000Z",
26 * "updatedDate": "2020-06-02T08:23:54.000Z",
27 * "name": "MySecondSecret",
28 * "description": "This is my second secret"
29 * }
30 * ]
31 * }
32 */
Retrieve a name and get a secret's value

Copy Code
1
2
3import { secrets } from 'wix-secrets-backend.v2';
4
5export function getFirstSecretValue() {
6 return secrets.listSecretInfo()
7 .then((secrets) => {
8 return secrets.getSecretValue(secrets[0].name);
9 })
10 .catch((error) => {
11 console.error(error);
12 });
13}
14
15/*
16 * Returns a Promise that resolves to:
17 *
18 * "Fm8OfflH6bJOwWjenqAtLurLbkiMNvmhQHZV+118"
19 */
Retrieve an ID and delete a secret

Copy Code
1
2import { secrets } from 'wix-secrets-backend.v2';
3
4export function deleteFirstSecret() {
5 return secrets.listSecretInfo()
6 .then((secrets) => {
7 return secrets.deleteSecret(secrets[0].id);
8 })
9 .then(() => {
10 console.log('Secret deleted');
11 })
12 .catch((error) => {
13 console.error(error);
14 });
15}