How to assign a Promise<string> to a string in typescript?

Viewed 35

I am using aws-sdk to get ssm parameter values from my aws account using typescript but it's throwing an error when I assign the returned value to a string variable. My code:

const getParameter = async (name:string) : Promise<string>   => {
  const params: aws.SSM.GetParameterRequest = { Name: name };

  const ssm = new aws.SSM({region: Region});
  const res = await ssm.getParameter(params).promise();
  return res.Parameter?.Value!;
}
const accountID: string = getParameter('account')

How do I convert the Promise<string> type to string type so that I can assign it to accountId

0 Answers
Related