I have my code like this, and I want to get the value of a promise and set it to one of my object keys.
const defaultConfig = {
s3: {
region: process.env.ENV_S3_REGION,
accessKeyId: juice.string('S3.ACCESS_KEY_ID', juice.MANDATORY), //THIS RETURNS A PROMISE
secretAccessKey: process.env.ENV_S3_SECRET_ACCESS_KEY
},
uploadConfig: {
bucket: process.env.ENV_UPLOAD_BUCKET
}
};
Normally I'd use async await for that on my other parts of my code, but if I intend to put value of it inside an object, how would you suggest I do that? Because that current code will just return me the value Promise(pending). Even if I place it inside the object like this,
s3: {
region: process.env.ENV_S3_REGION,
accessKeyId: async()=> await juice.string('S3.ACCESS_KEY_ID', juice.MANDATORY), //This returns a promise
secretAccessKey: process.env.ENV_S3_SECRET_ACCESS_KEY
}
I'd still get the same promise pending message or returns back the value as function. I cannot get the actual string value which is a secret key.