-
Notifications
You must be signed in to change notification settings - Fork 20
Migration
github-actions[bot] edited this page Dec 30, 2025
·
2 revisions
The responses of commands are wrapped in a record with type of SafeReturn<T, VaultError>.
This record contains two properties:
-
data: Thedataproperty for successful responses. The value depends on the command. -
error: Theerrorproperty for error responses. The type isVaultError, which is a subclass ofError.
Your editor/IDE might not detect any errors, so please make sure to update and verify correctness of every usage.
import { Client, VaultError } from '@litehex/node-vault';
const { data, error } = await vc.write({
path: 'secret/test',
data: {
foo: 'bar'
}
});
if (error) {
if (error instanceof VaultError) {
return console.log(`Panic Mode: ${error.message}`);
}
return console.log(error); // Probably fetch failed. Should we retry?
}
// The error is checked by the last statement above and the only possibility is the success response with the `data` property
console.log(error); // undefined
console.log(data); // { request_id: '...', lease_id: '...', ... }