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 (dashboard page code)
Copy Code
1import { secrets } from 'wix-secrets-backend.v2';23export function getSecretInfo() {4 return secrets.listSecretInfo()5 .then((secrets) => {6 return secrets;7 })8 .catch((error) => {9 console.error(error);10 });11}1213/* 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 */33
Get information about your secrets (export from backend code)
Copy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { secrets } from 'wix-secrets-backend.v2';34export const getSecretInfo = webMethod(Permissions.Anyone, () => {5 return secrets.listSecretInfo()6 .then((secrets) => {7 return secrets;8 })9 .catch((error) => {10 console.error(error);11 });12});1314/* Returns a Promise that resolves to:15 * {16 * "secrets": [17 * {18 * "id": "2eebccce-6c01-469d-a278-433fd96ba111",19 * "createdDate": "2020-05-26T06:16:46.000Z",20 * "updatedDate": "2020-05-28T12:21:10.000Z",21 * "name": "MyFirstSecret",22 * "description": "This is my first secret"23 * },24 * {25 * "id": "ef4b43d4-851d-4b52-a07f-9a500a888371",26 * "createdDate": "2020-06-02T08:23:54.000Z",27 * "updatedDate": "2020-06-02T08:23:54.000Z",28 * "name": "MySecondSecret",29 * "description": "This is my second secret"30 * }31 * ]32 * }33 */34
Retrieve a name and get a secret's value
Copy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { secrets } from 'wix-secrets-backend.v2';34export const getFirstSecretValue = webMethod(Permissions.Anyone, () => {5 return secrets.listSecretInfo()6 .then((secrets) => {7 return secrets.getSecretValue(secrets[0].name);8 })9 .catch((error) => {10 console.error(error);11 });12});1314/*15 * Returns a Promise that resolves to:16 *17 * "Fm8OfflH6bJOwWjenqAtLurLbkiMNvmhQHZV+118"18 */19
Retrieve an ID and delete a secret
Copy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { secrets } from 'wix-secrets-backend.v2';34export const deleteFirstSecret = webMethod(Permissions.Anyone, () => {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});16