I am trying to read a value from Vault using the NodeJS. I am posting here to ensure my approach is correct.
Using the https://github.com/kr1sp1n/node-vault library, I have the following snippet of code:
var params = {
apiVersion: 'v1',
endpoint: "https://localhost:8200",
token: "MY_TOKEN"
};
var vault = require("node-vault")(params);
vault.read('secret/mysecret/foo').then(v => {
console.log(v);
}).catch(e => console.error(e));
This returns the following block of JSON to me:
{ request_id: 'MY_ID',
lease_id: '',
renewable: false,
lease_duration: 100,
data: { value: 'MY_PASSWORD' },
wrap_info: null,
warnings: null,
auth: null }
Specifically, I need to fetch the value of data.value (i.e. I need to fetch 'MY_PASSWORD'.
Would I perform JSON parsing within the 'then' block instead of printing the JSON to the console log like I am currently?