Get a Component Credential

Get component credentials according to the tenant in the context. It is possible to retrieve the credentials through the name of the component or its id. It is also possible to parameterize to generate an exception if the credential is not found.
Note: The component must be imported as a dependency.

Get credential by component name example:

const credentials = require('linkapi-sdk/utils/credentials');

const generateException = true; // optional, generates an exception when the credential is not found - default is true

const credentialName = 'myCred'; // optional, search for a credential with a specific name instead of taking the first one

const credential = await credentials.getByComponentName('component', generateException);

Get credential by component ID example:

const credentials = require('linkapi-sdk/utils/credentials');

const generateException = true; // optional, generates an exception when the credential is not found - default is true

const credentialName = 'myCred'; // optional, search for a credential with a specific name instead of taking the first one

const credential = await credentials.getByComponentId('5df925c2cbc05c0010ce8b87', generateException);