node.js – async/await for aws sdk function
I am using a custom auth challenge to get the otp as response, with below code I am able to get the OTP. But, instead of promise how can I use async/await to get the response from intiateAuth.
const params = {
AuthFlow: ".......",
ClientId: "*********",
AuthParameters: {
"USERNAME": req.userName,
}
};
return new Promise((resolve, reject) => {
new AWS.CognitoIdentityServiceProvider().initiateAuth(params, (err, data) => {
if (err) {
console.log("Error in adminInitiateAuth: %s", err.message);
reject(false);
} else {
const otpResponse: IOTPResponseDetails = {
session: data.Session,
userName: data.ChallengeParameters.USERNAME,
}
resolve(otpResponse);
}
});
});
}```
Read more here: Source link