我可以将变量从导出处理程序传递到Javascript中的模块导出吗?

问题描述

试图将导出处理程序中异步调用的结果传递回module.exports,但是我无法传递该变量。有什么想法吗?

exports.handler = async (event,context) => {
  try {
    const data = await secretsManager.getSecretValue({
      SecretId: secretName,}).promise();

    if (data) {
      if (data.SecretString) {
        const secret = data.SecretString;
        const parsedSecret = JSON.parse(secret); 
        return {
          hrPool: {
            user: parsedSecret.username,password: parsedSecret.password,connectString: parsedSecret.host,poolMin: 10,poolMax: 10,poolIncrement: 0
          },secrets: parsedSecret,};
      }
      const binarySecretData = data.SecretBinary;
      return binarySecretData;
    }
  } catch (error) {
    console.log('Error retrieving secrets');
    console.log(error);
  }
};

module.exports = {
  hrPool
  };

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)