How can I convert the shell command output to an array so I can print variables as uniqueMetrics[0], uniqueMetrics[1] etc?
const uniqueMetrics = await execShellCommand('aws cloudwatch list-metrics --namespace AWS/ApiGateway | jq -r .Metrics[].Dimensions[].Name | sort -u')
console.log(uniqueMetrics);
output:
ApiId
ApiName
Stage
It seems the data is returned as follows with \r and \n.
[ 'ApiId\r\nApiName\r\nStage\r\n' ]
So I'm guessing I'd need to search and replace these strings first. Am I thinking right?